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. Scala 系列(四)—— 数组 Array

    一.定长数组 在 Scala 中,如果你需要一个长度不变的数组,可以使用 Array.但需要注意以下两点: 在 Scala 中使用 (index) 而不是 [index] 来访问数组中的元素,因为访问 ...

  2. C语言-MySQL单表查询(vs2013环境)

    一.首先配置项目属性: 1.打开mysql的安装路径,找到include文件夹和lib文件夹 如图: 2.在vs2013中, 打开项目–> 属性 –>VC++目录 如图: 把将nclude ...

  3. python入学代码

    liwenhu=100 if liwenhu>=90: print("你很棒") elif liwenhu>=80: print("你很不错") e ...

  4. 【JVM】jdk1.8-jetty-swap被占满问题排查

    背景 线上服务收到报警,报警内容:虚拟机swap区占用比例超过80%,如图: 本文着重描述排查问题的过程,在这个过程中不断的猜测–>验证–>推翻–>再猜测–>再验证–>再 ...

  5. ABAP-JCO服务错误

    1.错误如下图,需SM59调整Unicode,保持JCO服务启动时与SAP-SM59设置Unicode一致.

  6. OSX - Mac OS 10.12后Caps lock(大写键)无法使用的解决办法

    我在OSX的虚拟机中安装了windows 7 操作系统,但是发现在win7下,大写键不起作用,通过下面方面搞定了! ▲打开设置中的键盘选项,并切换至输入源选项标签, ▲取消勾选“使用大写锁定键来回切换 ...

  7. Java 参数个数可变的函数

    示例: package my_package; public class Test { public static void main(String[] args) { out("重庆师范大 ...

  8. 【RAC】 RAC For W2K8R2 安装--总体规划 (一)

    [RAC] RAC For W2K8R2 安装--总体规划 (一) 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一 ...

  9. go调度: 第二部分-go调度器

    前言 这个博客是三部分中提供go调度器的语义和机制的部分. 博客三部分的顺序: 1) go调度: 第一部分-操作系统调度 2) go调度: 第二部分-go调度器 3) go调度: 第三部分-并发 介绍 ...

  10. Flask入门很轻松 (一)

    转载请在文章开头附上原文链接地址:https://www.cnblogs.com/Sunzz/p/10956837.html Flask诞生于2010年,是Armin ronacher(人名)用 Py ...