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 ...
随机推荐
- Java 整体测试重点题 错题积累
重点题 错题积累 1: 解析: %d:用来设置输出日志的日期和时间 %m:用来输出代码中指定的消息 %n:用来输出一个回车换行符 %l:用来输出日志事件的发生位置 %p:用来输出优先级 %f:用 ...
- MFC 中GetClientRect、ClientToScreen、GetWindow、RectScreenToClient的使用
CWnd* pWnd = GetDlgItem(IDB_BUT_RECOGNIZE); pWnd->GetClientRect(&rect); //指该控件自身客户区的矩形,原点为控 ...
- 编程实现Linux系统的od功能
选做题目以及分析 题目:编写MyOD.java 用java MyOD XXX实现Linux下od -tx -tc XXX的功能 分析:我觉得这道题目中的参数应当是-tx1而不是-tx,使用了-tx后结 ...
- synchronized(四)
package com.bjsxt.base.sync005;/** * synchronized的重入 * @author alienware * */public class SyncDubbo1 ...
- Python学习笔记第二十周
目录: 一.ORM 1.查询补充 备注:forloop.counter介绍 二.Ajax 三.ORM多对多操作 内容: 一.ORM 1.查询补充: 1.models.USR.objects.all() ...
- Kafka高可用实现原理
数据存储格式 Kafka的高可靠性的保障来源于其健壮的副本(replication)策略.一个Topic可以分成多个Partition,而一个Partition物理上由多个Segment组成. Seg ...
- Caution: request is not finished yet
/********************************************************************** * Caution: request is not fi ...
- maven工程的多环境配置方案(profile)
前言: 写一篇水文来打发下时间吧^_^. 在应用开发中, 总会遇到开发/测试/预发布/线上环境, 其环境不同, 其具体的配置项也有所不同, 因此如何快速的切换各个环境配置, 进行打包配置, 成了一个小 ...
- Java中的IO流大体介绍
由于Java中的IO流是在是知识点繁多,所以我大约花了1周的时间将其整理起来.但是整理起来后并不是将完事了,我还是要分字节流和字符流来讲述.然后字节流和字符流中还有是否带有缓冲流. 讲述完IO流后我将 ...
- flask中利用from来进行对修改修改时旧密码的验证
在flask中,肯定是post提交个from进行密码验证.还有一定就是修改密码肯定是登录之后才能进行对密码的修改,这么说,在浏览器中的session中一定会有用户的信息,可以通过相对应的信息去获取到相 ...