graphql与rpc_探索GraphQL与BIGKit的集成

graphql与rpc

GraphQL is a pretty exciting technology, certainly one that is gaining a lot of traction at the moment. What is exciting about it, is that complex layering of parameterized subqueries is possible, all whilst being grounded to a fully typed schema. It covers not only querying, but mutations — a way to update data, and even subscriptions. It is also language agnostic, so your consuming technology can be whatever you currently are most comfortable with, aided by an appropriate library.

GraphQL是一项非常令人兴奋的技术,目前肯定会吸引很多人。 令人兴奋的是,有可能对参数化子查询进行复杂的分层,而所有这些都基于完全类型化的架构。 它不仅涵盖查询,还涵盖变异-一种更新数据甚至订阅的方式。 它也是与语言无关的,因此在适当的库的帮助下,您所使用的技术可以是您目前最满意的技术。

I have had this on my radar for some time, being interested but not having any reason to use it in anger. A few weeks ago, however, the penny dropped. BIGKit already has a lot of the prerequisites required to create a dynamically generated GraphQL endpoint: it has a type system, a schema, an abstract DSL around the Table Query engine, multi-tenanted databases, import/export.

我已经有一段时间了,对此很感兴趣,但没有任何理由愤怒使用它。 但是,几周前,一分钱掉了下来。 BIGKit已经具有创建动态生成的GraphQL端点所需的许多先决条件:它具有类型系统,模式,围绕表查询引擎的抽象DSL,多租户数据库,导入/导出。

The only missing piece was creating the interface between our domain, and an appropriate library designed to do the heavy lifting of constructing these endpoints. Luckily, such a library exists already, so thanks again to the f# community for creating FSharp.Data.GraphQL, which forms the foundation of this endpoint.

唯一缺少的部分是在我们的域和一个适当的库之间创建接口,该库旨在繁重地构建这些端点。 幸运的是,这样的库已经存在,因此再次感谢f#社区创建FSharp.Data.GraphQL ,它构成了此终结点的基础。

By going to the Data tab, you can now access a new API/GraphQL area, allowing you to configure API key access. For exploring the API surface, we suggest checking grapiql-online (for public access), or if you are a chrome user and want to be able to use API keys: graphql playground. On initial endpoint configuration, it will attempt to retrieve the schema, which is then consumed and used to provide the language service with auto-completion options. You may also wish to configure what auth mechanisms can be used with the GraphQL API in the “Settings” tab. Currently, you can incrementally enable and disable public access, API key access, and OIDC access for schema, read, and write. More granular field-level control is already functional but still needs some refinement.

通过转到“数据”选项卡,您现在可以访问新的API / GraphQL区域,从而可以配置API密钥访问。 为了探索API表面,我们建议您检查grapiql-online (以供公共访问),或者如果您是Chrome用户,并且希望能够使用API​​密钥,请执行以下操作: graphql游乐场 。 在初始端点配置上,它将尝试检索架构,然后使用该架构并将其用于为语言服务提供自动完成选项。 您可能还希望在“设置”选项卡中配置可以与GraphQL API一起使用的身份验证机制。 当前,您可以为模式,读取和写入逐步启用和禁用公共访问,API密钥访问和OIDC访问。 更加精细的字段级控制已经可以运行,但仍需要改进。

查询方式 (Querying)

Image for post

Each entity generates a queryable field, all of which can support optional parameters for id, skip and take along with a basic pass of the filter DSL. You can also already request deeply nested objects/lists/blob file references, along with entity time-travel, events, and foreign-keys.

每个实体都会生成一个可查询字段,所有字段都可以支持ID,跳过和过滤DSL的基本传递的可选参数。 您还可以请求深度嵌套的对象/列表/ blob文件引用,以及实体时间旅行,事件和外键。

Image for post

突变 (Mutation)

It is also possible to update an entity by id and any of its fields arbitrarily. As with all entity updates, events for field update deltas are automatically created in the background for auditing and reprojection purposes.

也可以通过id及其任何字段任意更新实体。 与所有实体更新一样,将在后台自动创建用于字段更新增量的事件,以进行审核和重新投影。

Image for post

Because there is nothing like trying this out yourself, we have provided a dummy public access API with a trivial schema in our documentation project available at: https://app.leansquad.co.uk/api/b701d9b0-004b-4462-83f5-43aa86502b31/476347052/3/gql

因为没有什么可以自己尝试的了,所以我们在我们的文档项目中提供了一个带有普通模式的虚拟公共访问API, 网址为: https : //app.leansquad.co.uk/api/b701d9b0-004b-4462-83f5 -43aa86502b31 / 476347052/3 / gql

有类型的React Client演示 (A typed react client demo)

I have also thrown together a demo repo to get started, which uses the fantastic graphql-zeus client generator, typescript, and react. You can clone it from here.

我还汇总了一个示例仓库 ,以开始使用该仓库 ,它使用了出色的graphql-zeus客户端生成器,打字稿和react。 您可以从这里克隆它。

To point it at your endpoint, you simply need to replace the path of your client in the package.json scripts section with your endpoint and rerun the generate-gql-client script. Bear in mind that the schema/introspection query will need to be run, so depending on what kind of auth header is provided, permissions need to be set correctly in BIGKit settings.

要将其指向端点,您只需要用端点替换package.json脚本部分中的客户端路径,然后重新运行generate-gql-client脚本即可。 请记住,将需要运行schema / introspection查询,因此根据所提供的auth标头的种类,需要在BIGKit设置中正确设置权限。

在结束时 (In closing)

Although this is still quite an early prototype, we are excited with the possibilities of allowing teams to integrate external applications. It is possible now to create a self-hosted SPA for fine-grained control and have it be entirely driven by our GraphQL backend. On top of this, hybrid approaches are also possible where data capture and management is handled by BIGKit and an external application then consumes the data, much like how a modern headless CMS works, with the fundamental difference that we do not have a publishing mechanism for individual entities. On the flip side though, we do have environments, so if there is a demand for this we could explore creating more granular ways of pushing data between these environments.

尽管这仍是一个早期的原型,但我们对允许团队集成外部应用程序的可能性感到兴奋。 现在可以创建用于精细控制的自托管SPA,并使其完全由我们的GraphQL后端驱动。 最重要的是,混合方法也是可行的,其中BIGKit处理数据捕获和管理,然后外部应用程序使用数据,就像现代无头CMS的工作方式一样,其根本区别在于我们没有发布机制个体实体。 但另一方面,我们确实有环境,因此,如果有此需求,我们可以探索创建更精细的方式在这些环境之间推送数据。

We would love your feedback on where we go with this. Some ideas that are on the radar:

我们希望收到您对我们的解决方案的反馈 。 备受关注的一些想法:

  • Enhance filter DSL

    增强过滤器DSL
  • More integration with entity events

    与实体事件的更多集成
  • Integration with Indexes (denormalised reprojections in elastic search)

    与索引集成(弹性搜索中的非规范化投影)
  • Triggers and custom queries — being able to define custom GraphQL mutation constructs with business logic using our Action system, thus potentially allowing typescript.

    触发器和自定义查询-能够使用我们的Action系统使用业务逻辑定义自定义GraphQL突变构造,从而潜在地允许使用打字稿。
  • GraphQL Scope in BIGKit application itself, allowing consumption of this and perhaps other external graphql api’s

    BIGKit应用程序本身中的GraphQL Scope,允许使用此以及其他外部graphql api的

As always, we welcome you to check out our samples, create a free account with us and get started today.

与往常一样,我们欢迎您查看我们的示例 ,在我们这里创建一个免费帐户并立即开始。

翻译自: https://medium.com/swlh/exploring-graphql-with-bigkit-d6c6236b3a5d

graphql与rpc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值