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. 【基本知识】FMS有限状态机设计

    有限状态机是Verilog中十分基本也是十分重要的知识.本文对有限状态机做了一个简单介绍. 1.状态机三要素 有限状态机具有三个要素:状态跳转.跳转判断.状态操作: 1)状态跳转:现态跳转到次态: 2 ...

  2. Geoserver发布强制显示标签处理

    TextSymbolizer 增加如下配置: <!--  标签重叠也显示  --> <VendorOption name="conflictResolution" ...

  3. Educational Codeforces Round 75 (Rated for Div. 2)

    知识普及: Educational使用拓展ACM赛制,没有现场hack,比赛后有12h的全网hack时间. rank按通过题数排名,若通过题数相等则按罚时排名. (罚时计算方式:第一次通过每题的时间之 ...

  4. Android EventBus使用大全

    添加依赖 implementation 'org.greenrobot:eventbus:3.1.1' public class HuaDongActivity extends Activity { ...

  5. 【转】Jperf2.0下载及使用方法介绍

    iPerf图形化工具Jperf图文使用教程   在前文介绍iPerf时,我们就提到了Jperf这款软件,因为iPerf没有图形界面,操作起来不是太方便,而Jperf则是将iPerf命令行图形化的JAV ...

  6. Linux实验:NTP网络时间服务器

    [实验目的]    1)掌握时间服务器的搭建方法    2)掌握客户机与时间服务同步时间的方法[实验原理]    NTP服务器[Network Time Protocol(NTP)]是用来使计算机时间 ...

  7. FreeBSD关机后自动重启的解决办法

    我用的是华硕的笔记本电脑,不知道别的电脑有没有这个情况,按handbook关机指令为shutdown -p now,但是我执行这个指令后电脑却自动重启,用Linux关机指令shutdown -h no ...

  8. Gtest:源码解析

    转自:玩转Google开源C++单元测试框架Google Test系列(gtest)之七 - 深入解析gtest 一.前言 “深入解析”对我来说的确有些难度,所以我尽量将我学习到和观察到的gtest内 ...

  9. 安装JDK(Windows)

    安装JDK java 安装JDK 下载JDK并安装 配置环境变量 变量名:JAVA_HOME 变量值:C:\Program Files\Java\jdk1.8.0_144 (jdk安装路径) 变量名: ...

  10. PAT甲级1012题解——选择一种合适数据存储方式能使题目变得更简单

    题目分析: 本题的算法并不复杂,主要是要搞清楚数据的存储方式(选择一种合适的方式存储每个学生的四个成绩很重要)这里由于N的范围为10^6,故选择结构体来存放对应下标为学生的id(N只有2000的范围, ...