转自: 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. 关于学习Vue的前置工作/技术储备

    关于学习Vue的前置工作/技术储备 1.GitBatch 2.Sublime Text 3.Node-----npm 命令 本人用的idea GitBatch: GitBatch是一个可以编写shel ...

  2. 【转载】JVM系列二:GC策略&内存申请、对象衰老

    JVM里的GC(Garbage Collection)的算法有很多种,如标记清除收集器,压缩收集器,分代收集器等等,详见HotSpot VM GC 的种类 现在比较常用的是分代收集(generatio ...

  3. IEDA中彻底删除项目

    删除项目一向比较奇葩,因为当你点击到 该项目名称-->右键 时,并没有 delete 选项,导致我们不知道怎么删除,查找多方文档,得到以下解决: (1)将鼠标移到要删除的 项目名称 上,单击并按 ...

  4. springMVC拦截css与js等资源文件的解决

    写了一个demo的ssm,使用jetty容器跑的,但是在页面的时候总是发现访问资源出现404. 换了多种写法不见效. 偶然发现日志中请求被springMVC拦截了,气死我了. 解决方式: Spring ...

  5. softmax与多分类

    sotfmax 函数在机器学习和深度学习中有着广泛的应用, 主要用于多分类问题. softmax 函数 1. 定义 假定数组V,那么第i个元素的softmax值为 也就是该元素的指数 除以 所有元素的 ...

  6. YLZ开发外网前端

    YLZ外网前端使用的是boottstrap和layer和validform等插件 表格是用boottstrap的tablle加上框架人员开发的ajaxpageresponse进行协调开发 弹窗使用的l ...

  7. crontab入门及进阶学习笔记

    crontab不是通常意义下的linux指令,它更是一个配置工具.通过这个工具,我们可以为系统定制固定周期的任务. 1.crond和crontab 1)   crond:cron服务的守护进程,用于定 ...

  8. Python 面向对象和面向过程对比

    # 大象装冰箱 # 脚本, 此时代码是最简单的. 不需要构思整个程序的概况 print("开门") print("装大象") print("关门&qu ...

  9. chrome插件 - Manifest文件中的 background

    在Manifest中指定background域可以使扩展常驻后台. background可以包含三种属性,分别是scripts.page和persistent. 如果指定了scripts属性,则Chr ...

  10. table中head表头固定,body滚动

    <style type="text/css"> .table-head { background-color: #; color: #; } .table-body { ...