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. checkbox之全选和反选

    先导入jquery组件 <input type="checkbox" id="checkall">全选<input type="ch ...

  2. The four Day 给出一个平衡字符串,将它分割成尽可能多的平衡字符串

    """ 在一个「平衡字符串」中,'L' 和 'R' 字符的数量是相同的. 给出一个平衡字符串 s,请你将它分割成尽可能多的平衡字符串. 返回可以通过分割得到的平衡字符串的 ...

  3. Entity framework Core 数据库迁移

    本文转自https://www.cnblogs.com/zmaiwxl/p/9454177.html 初始化数据库 1.添加初始迁移 Add-Migration init 向“迁移”目录下的项目添加以 ...

  4. Matlab原型模式

    原型(Prototype)模式的定义如下:用一个已经创建的实例作为原型,通过复制该原型对象来创建一个和原型相同或相似的新对象.Matlab面向对象编程有两种类,一种是Value Class,一种是Ha ...

  5. Eclipse - 安装Indent Guide,使JAVA代码具备编辑缩进线,和Delphi一样酷!!

    Delphi里面默认就有代码编辑缩进线,这在编写逻辑复杂的大块代码时候非常有好处,可以清楚地看到每块代码的范围,下面就是Delphi里面代码编辑缩进线的截图: 非常棒的效果,我喜欢,在处理复杂逻辑代码 ...

  6. win10 提示该文件没有与之关联的应用来执行该操作

    将下面代码复制进一个文本文档,然后将文本文档的txt后缀改成bat.双击运行,可以解决问题. 问题发生原因是之前通过注册表去除了桌面图标的快捷方式的小标志. /-------------------- ...

  7. TensorFlow 2 快速教程,初学者入门必备

    TensorFlow 2 简介 TensorFlow 是由谷歌在 2015 年 11 月发布的深度学习开源工具,我们可以用它来快速构建深度神经网络,并训练深度学习模型.运用 TensorFlow 及其 ...

  8. ansible运维工具,dhcp,cobbler

    1.借助Ansible Playbook自动化搭建LNMP环境(可借助yum) 通过yum方式安装ansible,先安装epel仓库 yum install epel-release 安装epel仓库 ...

  9. springboot+mybatis +yml文件配置多数据源

    记录一下java开发中多数据源的配置过程, 参考博客:https://blog.csdn.net/weinichendian/article/details/72903757,我在这里进行了整理,使用 ...

  10. The Instruction Set In Cortex-M3

    The Cortex-M3 supports the Thumb-2 instruction set. This is one of the most important features of th ...