GraphQL Gateway Architectures
转自: 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:
- All services that expose some graphQL schema will be a graphQL server, exposing the usual
/graphqlendpoint. - 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的更多相关文章
- 使用merge-graphql-schemas 进行graphql schema 以及resovler 合并
merge-graphql-schemas 是一个方便的工具,可以进行schema 以及resovler 的合并处理 一个schema 合并参考demo schema 定义 // ./graphql/ ...
- 基于 GraphQL 的 BFF 实践
随着软件工程的发展,系统架构越来越复杂,分层越来越多,分工也越来越细化.我们知道,互联网是离用户最近的行业,前端页面可以说无时无刻不在变化.前端本质上还是用户交互和数据展示,页面的高频变化意味着对数据 ...
- QLoo graphql engine 学习一 基本试用(docker&&docker-compose)
说明:使用docker-compose 进行安装 代码框架 使用命令行工具创建 qlooctl install docker qloo-docker 运行qloo&&gloo 启动 ...
- hasura graphql 模式拼接概念
具体的使用可以参考下面一张图 有一个术语 graphql-bindings 参考项目: https://github.com/hasura/generate-graphql-bindings http ...
- 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 ...
- Uber的API生命周期管理平台边缘网关(Edge Gateway)的设计实践
设计边缘网关(Edge Gateway),一个高可用和高可扩展的自助服务网关,用于配置.管理和监控 Uber 每个业务领域的 API. Uber 的 API 网关的演进 2014 年 10 月,优步开 ...
- 记一次nginx部署yii2项目时502 bad gateway错误的排查
周六闲来无事,就试着安装和部署下yii2,安装过程没什么问题,但部署到nginx上时遇到了502 bad gatewary问题,折腾了半天才搞定.这个问题是我以前在部署yii2时没有遇到过的,因此记在 ...
- tomcat 504 gateway time-out
今天有个环境ajax调用一个请求的时候,出现一个504 gateway time-out响应,原以为是nginx找不到资源的问题,恰当我们的服务器上又配置了nginx,看了配置文件,没有指向tomca ...
- linux查看本机IP、gateway、DNS
IP: ifconfig gateway:[root@localhost ~]# netstat -rnKernel IP routing tableDestination Gatew ...
随机推荐
- vue-14-过滤
过滤器可以用在两个地方:mustache 插值和 v-bind 表达式 <!-- in mustaches --> {{ message | capitalize }} <!-- i ...
- Linux文件管理常用命令用法总结
1.touch change file timestamps. 命令用于修改文件或者目录的时间属性,包括存取时间和更改时间.若文件不存在,系统会建立一个新的文件.stat,ls -l 可以显示档案的时 ...
- spin lock自旋锁 双链表操作(多线程安全)(Ring0)
通过spin lock自旋锁 ,为每个链表都定义并初始化一个锁,在需要向该链表插入或移除节点时不使用前面介绍的普通函数,而是使用如下方法: ExInterlockedInsertHeadList(&a ...
- easyui再学习的一部分代码
<%-- Created by IntelliJ IDEA. User: zhen Date: // Time: : To change this template use File | Set ...
- Linux文件系统命令 cp
命令名:cp 功能:拷贝文件,把一个文件的内容拷贝到另外一个文件中去. eg: cp source_file dist_file renjg@renjg-HP-Compaq-Pro--MT:~$ cp ...
- connection reset 分析解决(转载)
文章转自:https://my.oschina.net/xionghui/blog/508758;记录下来以便以后复习查阅; 在使用HttpClient调用后台resetful服务时,“Connect ...
- php优秀框架codeigniter学习系列——common.php
文件位于system/core/common.php,是框架核心文件. 该文件中定义了一系列的函数,都是框架运行中经常需要用到的.下面逐一介绍. is_php /** * Determines if ...
- apache .htacess
htaccess 详解 .htaccess是什么 .htaccess文件(或者"分布式配置文件")提供了针对目录改变配置的方法, 即,在一个特定的文档目录中放置一个包含一个或多 ...
- python-tornado和django优缺点
Django优点: 大和全(重量级框架)自带orm,template,view 需要的功能也可以去找第三方的app注重高效开发全自动化的管理后台(只需要使用起ORM,做简单的定义,就能自动生成数据库结 ...
- python DRF获取参数介绍
DRF获取参数的方式 例如url url(r'^demo/(?P<word>.*)/$', DemoView.as_view()) 在类视图中获取参数 url:http://127.0.0 ...