0

I have a GraphQL schema set up that successfully supports queries. However when attempting a mutation I get the following strange error: Error "message": "GraphQL.Validation.ValidationError: Cannot query field \"id\" on type \"IdeaInput\". Did you mean \"id\"?"

Here's the input type for the mutation:

    public class IdeaInputType : InputAuditableGraphType<Idea>
    {
        public IdeaInputType()
        {
            Name = "IdeaInput";
            Description = "Create idea";
            Field(x => x.Id);
            Field(x => x.Name, true);
            Field(x => x.Summary);
        }
    }

And the data:

enter image description here

This error is returned for the other fields. I've even tried explicitly naming the fields, but the error persists. What could cause this to fail when the expected name and received name are ostensibly identical?

snort
  • 2,285
  • 3
  • 19
  • 21

1 Answers1

0

In case this helps anyone, I found that I was using the wrong Field type for the mutation. The field must have the query type and the argument must have the mutation (input) type:

public MyMutation()
{
    Name = "Root mutation";
    Field<IdeaType>(
                   "createIdea",
                   arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdeaInputType>> { Name = "idea" }),
                   resolve: context => {...}
}

This explains why the expected and received field names were the same in the error. Same name on different types.

snort
  • 2,285
  • 3
  • 19
  • 21