merge-graphql-schemas 是一个方便的工具,可以进行schema 以及resovler 的合并处理

一个schema 合并参考demo

  • schema 定义
// ./graphql/types/clientType.js
export default `
  type Client {
    id: ID!
    name: String
    age: Int
    products: [Product]
  }
  type Query {
    clients: [Client]
    client(id: ID!): Client
  }
  type Mutation {
    addClient(name: String!, age: Int!): Client
  }
`;
// ./graphql/types/productType.js
export default `
  type Product {
    id: ID!
    description: String
    price: Int
    client: Client
  }
  type Query {
    products: [Product]
    product(id: ID!): Product
  }
`;
  • 合并
// ./graphql/types/index.js
import { mergeTypes } from 'merge-graphql-schemas';
import clientType from './clientType';
import productType from './productType';
const types = [
  clientType,
  productType,
];
// NOTE: 2nd param is optional, and defaults to false
// Only use if you have defined the same type multiple times in
// different files and wish to attempt merging them together.
export default mergeTypes(types, { all: true });

说明

如果在早期项目规划schema 约定还是比较好的时候merge-graphql-schemas 还是一个不错的方案
同时已经好好多解决方案了,apollo 团队的联邦还是很不错的,使用此功能,我们可以方便的进行graphql
api 聚合,如果对于后端约定比较好的,做为graphql gateway 的一个工具也是不错的

参考资料

https://github.com/Urigo/merge-graphql-schemas

使用merge-graphql-schemas 进行graphql schema 以及resovler 合并的更多相关文章

  1. [GraphQL] Write a GraphQL Schema in JavaScript

    Writing out a GraphQL Schema in the common GraphQL Language can work for simple GraphQL Schemas, but ...

  2. Modularizing your graphQL schemas

    转自: https://tomasalabes.me/blog/nodejs/graphql/2018/07/11/modularizing-graphql.html Modularizing you ...

  3. [GraphQL] Serve a GraphQL Schema as Middleware in Express

    If we have a GraphQL Schema expressed in terms of JavaScript, then we have a convenient package avai ...

  4. [GraphQL] Create a GraphQL Schema

    we’ll take a look at the GraphQL Language and write out our first GraphQL Schema. We’ll use the grap ...

  5. Araxis Merge Professional v2014.4565 特别版 | 文件比较合并

    http://www.ttrar.com/html/AraxisMerge.html Araxis Merge 是一个可视化的文件比较.合并和同步的软件,能够方便的被软件工程师和 web 站点开发者使 ...

  6. graphql cli 开发graphql api flow

    作用 代码生成 schema 处理 脚手架应用创建 项目管理 安装cli npm install -g graphql-cli 初始化项目(使用.graphqlconfig管理) 以下为demo de ...

  7. Reusing & Composing GraphQL APIs with GraphQL Bindings

    With GraphQL bindings you can embed existing GraphQL APIs into your GraphQL server. In previous blog ...

  8. [GraphQL] Deploy a GraphQL dev playground with graphql-up

    In this lesson we'll use a simple GraphQL IDL schema to deploy and explore a fully functional GraphQ ...

  9. [GraphQL] Write a GraphQL Mutation

    In order to change the data that we can query for in a GraphQL Schema, we have to define what is cal ...

随机推荐

  1. Kibana访问报错

    浏览器访问提示:Kibana server is not ready yet 查看日志如下 {"type":"log","@timestamp&quo ...

  2. Scala 系列(三)—— 流程控制语句

    一.条件表达式if Scala 中的 if/else 语法结构与 Java 中的一样,唯一不同的是,Scala 中的 if 表达式是有返回值的. object ScalaApp extends App ...

  3. navicat连接mysql出现2059

    1.找到mysql的目录:C:\Program Files\MySQL\MySQL Server 8.0\bin 2.清空此目录,输入cmd,回车 3.在控制台输入:mysql -u root -p ...

  4. 相似文档查找算法之 simHash及其 java 实现

    传统的 hash 算法只负责将原始内容尽量均匀随机地映射为一个签名值,原理上相当于伪随机数产生算法.产生的两个签名,如果相等,说明原始内容在一定概 率 下是相等的:如果不相等,除了说明原始内容不相等外 ...

  5. linux 安装Python3.6

    1.安装依赖 yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel ...

  6. python入门基础思维导图

  7. 百度地图 libBaiduMapSDK_base_v4_2_1.so" is 32-bit instead of 64-bit错误

    20191111 集成android sdk,华为手机基本都启动报错,如下: W/System.err: java.security.NoSuchProviderException: no such ...

  8. Angular使用操作事件指令ng-click传多个参数示例

    本文实例讲述了Angular使用操作事件指令ng-click传多个参数功能.分享给大家供大家参考,具体如下: <!DOCTYPE html> <html ng-app="m ...

  9. Firebird 事务隔离级别

    各种RDBMS事务隔离都差不多,Firebird 中大致分为3类: CONCURRENCY.READ_COMMITTED.CONSISTENCY. 在提供的数据库驱动里可设置的事务隔离级别大致如下3类 ...

  10. jmeter学习笔记(二十二)——监听器插件之jp@gc系列

    一.jp@gc - Actiive Threads Over Time 不同时间活动用户数量展示 下面是一个阶梯加压测试的图标   二.jp@gc - Transactions per Second ...