转自: https://tomasalabes.me/blog/graphql/node/microservices/2018/08/11/graphql-architectures.html

GraphQL Gateway Architectures

These are the approaches we will see:

  • Remote Schema Stitching
  • Schema Stitching through Shared Interfaces
  • Hybrid Remote Schema Stitching
  • Using Prisma’s graphQL Bindings

Let’s start.

Remote schema stitching

Stitching strategy

  • The gql gateway builds the schema exposed to the client as a mashup of many remote graphql schemas (link)

    • This lets the graphql servers evolve independently from the gateway but
  • The dynamic nature of this can be tricky, as the final API is “dispersed”, interaction between schemas can become complicated, maybe needing the following:
    • You might have merge conflicts (more) or transformations (more)
    • Without proper testing, remote schemas might change and the gateway becomes out of date / broken
  • All services that expose some graphQL schema will be a graphQL server, exposing the usual /graphql endpoint.
  • Each service can choose in what language implement the graphQL server

Schema stitching through shared interfaces

NPM interfaces strategy

  • The gql gateway builds the schema exposed to the client as a mashup of many local graphql schemas (more)
  • These schemas are installed as npm packages
  • Development is easier as you have the schemas installed locally and you have the “source of truth” for the final API
  • The gateway will became a bottleneck, being modified by many teams as it has all resolvers and types
  • A change in any resolver or schema means redeploying the gql gateway and the service (high cohesion)

Hybrid Remote Schema Stitching

Hybrid resolvers strategy

This is a very simple variation from the previous 2 architectures. It’s just being able to not only delegate requests to other graphQL servers through schema stitching but also contain resolvers for other services.

  • The graphQL gateway communicates with Service A through a resolver implementation in the gateway itself (approach #2)
  • The graphQL gateway communicates with Service B through schema stitching (approach #1)

Using Prisma’s graphQL Bindings

This approach uses prima’s graphQL bindings. Think of it as a client built from a graphQL schema and its resolvers.

Prisma Bindings

So the collaboration diagram would be something like

Bindings strategy

Where

  • Service A and B publish a binding with all the resolvers for their types, queries and mutations
  • These bindings are consumed by the gateway and used to communicate with these services
  • This avoids the actual resolvers implementation in the gateway, and even in the services themselves
  • The development of the resolvers is done by the team developing the service in question

Conclusion

As always, your choice depends on many factors. Team, knowledge, time, etc. Some are simpler, some are more decoupled, some require more work.

Pick yours and give me your opinion! Or propose more!

Cheers

GraphQL Gateway Architectures的更多相关文章

  1. 使用merge-graphql-schemas 进行graphql schema 以及resovler 合并

    merge-graphql-schemas 是一个方便的工具,可以进行schema 以及resovler 的合并处理 一个schema 合并参考demo schema 定义 // ./graphql/ ...

  2. 基于 GraphQL 的 BFF 实践

    随着软件工程的发展,系统架构越来越复杂,分层越来越多,分工也越来越细化.我们知道,互联网是离用户最近的行业,前端页面可以说无时无刻不在变化.前端本质上还是用户交互和数据展示,页面的高频变化意味着对数据 ...

  3. QLoo graphql engine 学习一 基本试用(docker&&docker-compose)

      说明:使用docker-compose 进行安装 代码框架 使用命令行工具创建 qlooctl install docker qloo-docker 运行qloo&&gloo 启动 ...

  4. hasura graphql 模式拼接概念

    具体的使用可以参考下面一张图 有一个术语 graphql-bindings 参考项目: https://github.com/hasura/generate-graphql-bindings http ...

  5. Why GraphQL is Taking Over APIs

    A few years ago, I managed a team at DocuSign that was tasked with re-writing the main DocuSign web ...

  6. Uber的API生命周期管理平台边缘网关(Edge Gateway)的设计实践

    设计边缘网关(Edge Gateway),一个高可用和高可扩展的自助服务网关,用于配置.管理和监控 Uber 每个业务领域的 API. Uber 的 API 网关的演进 2014 年 10 月,优步开 ...

  7. 记一次nginx部署yii2项目时502 bad gateway错误的排查

    周六闲来无事,就试着安装和部署下yii2,安装过程没什么问题,但部署到nginx上时遇到了502 bad gatewary问题,折腾了半天才搞定.这个问题是我以前在部署yii2时没有遇到过的,因此记在 ...

  8. tomcat 504 gateway time-out

    今天有个环境ajax调用一个请求的时候,出现一个504 gateway time-out响应,原以为是nginx找不到资源的问题,恰当我们的服务器上又配置了nginx,看了配置文件,没有指向tomca ...

  9. linux查看本机IP、gateway、DNS

    IP:     ifconfig gateway:[root@localhost ~]# netstat -rnKernel IP routing tableDestination     Gatew ...

随机推荐

  1. delete请求

    Action(){ int HttpRetCode; //定义一个变量,用于接收HTTP返回的状态码 web_add_header("Session-Id", "2e25 ...

  2. 玩转X-CTR100 l STM32F4 l AT24C02 EEPROM存储

    我造轮子,你造车,创客一起造起来!塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ]      本文介绍X-CTR100控制器 板载EEP ...

  3. DevExpress WPF v18.2新版亮点(三)

    买 DevExpress Universal Subscription  免费赠 万元汉化资源包1套! 限量15套!先到先得,送完即止!立即抢购>> 行业领先的.NET界面控件2018年第 ...

  4. oracle语句优化

    摘录来自https://blog.csdn.net/sap_jack/article/details/3766703 1.选用适合的Oracle优化器 Oracle的优化器共有3种: a.RULE(基 ...

  5. 20165214 预备作业3 Linux安装及学习

    一.VirtualBox和Ubuntu的安装 点进VirtualBox的官网后,不知道为什么,我只看到了5.2.6版本...又看到同学反映说5.2.7版本会出现问题,我想可能是工作人员正在补5.2.7 ...

  6. L300 3月英语课下

    重音 句中的实词(内容词)要被重读,读得重.长一点.句中的虚词(功能词)要被轻读或弱读,读得轻.短一点口语交流中,当虚词的在句中起到重要的表意作用时,会被重读. 连读 连读:把一个单词的尾音同下一个单 ...

  7. 解决Invalid bound statement (not found): com.cqupt.ssm.dao.UserDao.queryMenu问题

    今天写项目时多加了个查询菜品的方法报错: Invalid bound statement (not found): com.cqupt.ssm.dao.UserDao.queryMenu 大概意思是找 ...

  8. VSFTP服务配置

    FTP连接及传输模式控制连接:TCP 21 ,用于发送FTP命令信息数据连接:TCP 20 ,用于上传.下载数据数据连接的建立类型:主动模式.被动模式 主动模式:服务器主动发起数据连接·首先由客户端向 ...

  9. File类操作中的IOException异常

     代码: File file= newFile("demo"+File.separator+"HelloWorld.txt"); file.createNe ...

  10. ES6 class的继承-学习笔记

    1.简介 Class 可以通过extends关键字实现继承,这比 ES5 的通过修改原型链实现继承,要清晰和方便很多. 子类必须在constructor方法中调用super方法,否则新建实例时会报错. ...