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. cocos creator图片渲染问题!

    问题:游戏项目需要添加一个开场剧情(); 第一时间使用了cc.component.scheduleOnce (), 里面的回调函数为 cc.loader.loadRes(). 进入游戏时,渲染主场景后 ...

  2. linux 压力测试工具之ab

    简介 Apache Benchmark(简称ab) 是Apache安装包中自带的压力测试工具 ,简单易用 在此提供 ab 在 centOS7 下的安装和使用方法注:个人发现,之前安装的centos6. ...

  3. spring boot 分布式锁组件 spring-boot-klock-starter

    基于redis的分布式锁spring-boot starter组件,使得项目拥有分布式锁能力变得异常简单,支持spring boot,和spirng mvc等spring相关项目 快速开始 sprin ...

  4. 2019 搜狐java面试笔试题 (含面试题解析)

      本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.搜狐等公司offer,岗位是Java后端开发,因为发展原因最终选择去了搜狐,入职一年时间了,也成为了面试官,之 ...

  5. LRU(Least Recently Used)算法的理解

    https://blog.csdn.net/wydyd110/article/details/84023688 感谢 ,自己学习记笔记 内存里建立一个哈希表,后来数据多了,爆了.咋整呢? 一个算法,就 ...

  6. 1+X证书学习日志——javascript基础

    js javascript js的组成: ECMAscript DOM BOM js放置的位置 <script></script> <script src="路 ...

  7. 在windows上搭建hadoop开发环境

    下载hadoop: http://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common 点击下面链接进行下载 然后进行解压 如果解压出现下面的情况 则用管 ...

  8. linux ftp虚拟用户的创建

    学习目标: 匿名用户的登录,添加用户的登录,虚拟用户的创建. 虚拟用户的创建: 1.安装:yum -y install vsftpd    服务端 yum -y install ftp         ...

  9. Linux-firewall防火墙

    systemctl status firewalld firewall-cmd --zone=public --list-ports ##查看已开放的端口 2.添加5901端口到白名单 执行 fire ...

  10. 关于Spring IOC (DI-依赖注入)你需要知道的一切

    <Spring入门经典>这本书无论对于初学者或者有经验的工程师还是很值一看的,最近花了点时间回顾了Spring的内容,在此顺带记录一下,本篇主要与spring IOC相关 ,这篇博文适合初 ...