Why does this throw "Cannot return null for non-nullable field Query.hello."?

Viewed 208

I had a GraphQL server that I swear worked just a few weeks ago, but now, it's suddenly throwing "cannot null non-nullable field" errors.

Yes, I have checked for duplicates. Yes, I have googled it. Yes, I have checked for related GitHub issues.

I created a minimal repro here: https://stackblitz.com/edit/graphql-drkgtc?file=index.js. Either I'm tired, or there's some breaking change in a minor package version somewhere that I missed.

Does anyone have an idea what is going on here?

1 Answers

Try this object for root variable:

var root = {
  Query: {
    hello:() => {return {hello :'hello'}}
  }
};

Related