Using GraphQL.NET, I've defined a non nullable return type (e.g. LoginPayload
) for a mutation like this:
type MyMutation {
login(input: LoginInput!): LoginPayload!
}
In C#, it looks something like this:
FieldAsync<NonNullGraphType<LoginPayloadType>>(
"login",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<LoginInputType>> { Name = "input" }),
resolve: async context =>
{
//...
});
Based on this schema definition, the client expects the response data to never be null. However, if there's an exception thrown in the resolver, GraphQL.NET responds like this:
{
"data": {
"login": null
},
"errors": [
{
"message": "GraphQL.ExecutionError: some exception thrown",
...
}
]
}
How can I configure GraphQL.Net to exclude the data
property when there's an error so it looks like this?
{
"errors": [
{
"message": "GraphQL.ExecutionError: some exception thrown",
...
}
]
}