Query works Mutations fail: Expected non-null value, resolve delegate return null

Query works Mutations fail: Expected non-null value, resolve delegate return null


1

I have a GraphQL .Net Core server and queries resolve wonderfully. Mutations however are failing with this error.

"message": "Expected non-null value, resolve delegate return null for "$GraphQLCore.Types.SInputType"",

I understand that you do not reuse your query types for mutations and I have created separate types but I’m still missing something.

public class SInputType : InputObjectGraphType
{
    public SInputType()
    {
        Field<IntGraphType>("sid");
         ...etc
    }
}

public class SUpdateMutation : ObjectGraphType
{
    MutationMock mm = new MutationMock();

    public SUpdateMutation()
    {
        Field<SInputType>(
            "createSrecord", 
            arguments: new QueryArguments(new QueryArgument<SInputType> 
                       { Name = "sticker"}),
            resolve: context => {
                var _stik = context.GetArgument<SModel>("stick");
                return mm.StockMutation(stick);
            });
    }

}

Everything I come up with on Google is related to NOT using a InputObjectGraphType but I am and from the examples I see I am using it correctly.

What can I try next?

1 Answer
1


1

The error was misleading me.

That error throws when you aren’t using the InputObjectGraphType BUT it also throws when you forget to add your new InputType to the sevicesCollection.

Adding this line fixed it.

services.AddSingleton<SInputType>();



Leave a Reply

Your email address will not be published. Required fields are marked *