在输入类型上有一个JSON字典字段用于变异

时间:2018-04-10 06:18:14

标签: c# graphql graphql-dotnet

我正在尝试创建一个采用输入类型FooInputType的突变。我的问题是在该输入上有一个字段来表示JSON字典(字符串字符串)。例如,foo.tags字段可以包含任何类型为字符串的键值对。

样本突变:

{
  "query": "mutation ($foo: FooInputType) { addFoo(foo: $foo) { tags } }",
  "variables": {
    "foo": { "bar": "test", "tags": { "priority": "high" } }
  }
}

这是突变:

class MyMutation : ObjectGraphType {
    public MyMutation() {
        Field<TaskItemType>("addFoo", "Add a new foo",
            new QueryArgument<FooInputType> {Name = "foo"}
        );
    }
}

输入类型:

class FooInputType : InputObjectGraphType {
    public FooInputType() {
        Field<StringGraphType>("bar");
        Field<InputObjectGraphType<JObject>>("tags");
    }
}

0 个答案:

没有答案
相关问题