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. python_dict json读写文件

    命令汇总: json.dumps(obj) 将python数据转化为json Indent实现缩进,ensure_ascii 是否用ascii解析 json.loads(s) 将json数据转换为py ...

  2. gym101480

    A. ASCII Addition 模拟 #include <iostream> #include <sstream> #include <algorithm> # ...

  3. Partition5:Partiton Scheme是否指定Next Used?

    在SQL Server中,为Partition Scheme多次指定Next Used,不会出错,最后一次指定的FileGroup是Partition Scheme的Next Used,建议,在执行P ...

  4. dump net core windbg 安装

    安装 1.下载工具windbg 地址:https://www.microsoft.com/zh-cn/p/windbg-preview/9pgjgd53tn86?SilentAuth=1&rt ...

  5. NEST 自定义分析器

    public void SetAnalysis() { if (!client.IndexExists("employee").Exists) { client.CreateInd ...

  6. WinForm下开发插件DevExpress安装及使用

    WinForm下开发插件DevExpress安装及使用在Visual Studio中安装DevExpress开发插件插件的使用方法简单的Demo介绍下载链接:https://pan.baidu.com ...

  7. 水泥caement单词

    Caement英语单词,翻译为:水泥 中文名:水泥 外文名:caement 目录 释义 caement 读音:英 [sɪˈment] 美 [sɪˈmɛnt] Noun名词. 水泥; caement在英 ...

  8. 有价证券secuerity英语

    证券业 证券业是为证券投资活动服务的专门行业.各国定义的证券业范围略有不同.按照美国的 “产业分类标准”,证券业由证券经纪公司.证券交易所和有关的商品经纪集团组成.证券业在世界各国都是一个小的产业部门 ...

  9. MySQL Replication--半同步复制(Semi-Sync Replication)

    半同步复制 默认配置下,MYSQL主从库通过binlog来保持一致,主库事务提交后,将binlog日志写入磁盘,然后返回给用户,备库通过拉取主库的binlog来同步主库的操作,无法保证主备节点数据实时 ...

  10. RocketMQ-Console安装

    1.获取源码 git clone -b release-rocketmq-console- https://github.com/apache/rocketmq-externals.git 2.进入工 ...