在C#中构建graphQL查询的建议 [英] Advice on building graphQL queries in c#

查看:179
本文介绍了在C#中构建graphQL查询的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个数据迁移项目-API到API.

I am working on a data migration project - API to API.

目标API是graphQL,我们有许多对象要推送到目标中,并且形状各不相同,因此我正在寻找有关如何最好地动态构建特定于c#的突变/查询的建议.

The destination API is graphQL, we have a number of objects to push into the destination and the shapes vary so I am looking for some advice on how best to dynamically build mutations/queries specifically in c#.

当前,我们仅使用模板,并使用查找/替换例程来注入值.尽管这种方法确实可以随着数据形状的变化而起作用,但它变得越来越复杂和微不足道.

Currently we are just using templates and using find/replace routines to inject values. While this approach does work as the shapes of the data vary this becomes evermore complex and inelegant.

我正在寻找可能有类似情况或知道我应该查看的任何库的任何建议/指针.

I am looking for any advice/pointers from anyone who have may have had a similar scenario or knows of any libraries I should look at.

推荐答案

我正在研究类似的问题.如我所见,需要对GraphQL突变和查询进行建模.使用C#对象表示您的实体,您可以实现自定义序列化程序,以遍历属性(通过反射)并输出所需的GraphQL输出.

I'm working on a similar problem. As I see it there is a need model the GraphQL mutations and queries. Using C# objects to represent your entities, you can implement a custom serialiser the walks the properties (via reflection) and outputs the required GraphQL output.

我将在此处发布一些示例代码...

I'll post back here with some sample code...

这篇关于在C#中构建graphQL查询的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆