I have a .NET Core Web API and I am using in-browser GraphiQL for testing my API. Here is my query and the error I got.
My Schema class:
public class DeveloperSchema : Schema
{
public DeveloperSchema(IDependencyResolver resolver) : base(resolver)
{
Query = resolver.Resolve<DevelopersQuery>();
Mutation = resolver.Resolve<DevelopersMutation>();
}
}
My Mutation class:
public class DevelopersMutation : ObjectGraphType
{
public DevelopersMutation(DevelopersContext _developersContext)
{
Field<DeveloperType>(
"CreateDeveloper",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<DeveloperInputType>> { Name = "developer" }
),
resolve: context =>
{
var developer = context.GetArgument<Developer>("developer");
return _developersContext.AddDeveloper(developer);
});
}
}
InputType for developer:
public class DeveloperInputType : InputObjectGraphType
{
public DeveloperInputType()
{
Name = "DeveloperInput";
Field<NonNullGraphType<IdGraphType>>("Id");
Field<StringGraphType>("Name");
}
}
Developer model:
public class Developer
{
public int Id { get; set; }
public string Name { get; set; }
}
I am using GraphQL 2.4.0, GraphiQL 3.4.0, .NET Core 3.1
I did not share my controller and QueryType structure since my query calls are working fine. I am having trouble with mutation calls.