In the API I am developing this graphql query
query { user(id: "nonexistentID") { name email } }
returns
{
"data": {
"user": {
"name": null,
"email": null
}
}
}
But I'd like it to return null on the user like this:
{
"data": {
"user": null
}
}
so the API-user knows that there's no such user. Is this intended behaviour or am I missing something?
The schema definition in graphql-js(express) looks like this:
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
user: {
type: userType,
args: {
id: { type: GraphQLString}
},
resolve: function resolve(root, args, info) {
return adapters.users.byId(args.id);
}
}
}
})
});