Graphql-tools: make allowUndefinedInResolve true by default

Created on 6 Aug 2016  路  8Comments  路  Source: ardatan/graphql-tools

During the upgrade from 0.1.0, this hit us pretty hard. Any reason why it wouldn't be true by default?

https://github.com/apollostack/graphql-tools/blob/master/src/schemaGenerator.js#L73

Most helpful comment

I see, in that case it would be more convenient if it were true by default. I'm definitely open to changing that, just go ahead and make a PR.

All 8 comments

@jbaxleyiii interesting. Do you have an example where returning undefined from a resolver is necessary and actually intended?

In my code, I generally return null if child resolvers shouldn't run. When a resolver returns undefined, that was generally because I misspelled something, or tried to access a field that doesn't exist. allowUndefinedInResolvers = false allowed me to find those bugs faster.

@helfer for optional data its a lot easier in resolvers to return a possible undefined variable, rather than variable || null.

https://github.com/NewSpring/Heighliner/blob/master/src/apollos/models/users/resolver.ts#L14

^^ that vs the rest of the resolvers where the return variable (for instance PersonId) could be undefined as it's not required

I see, in that case it would be more convenient if it were true by default. I'm definitely open to changing that, just go ahead and make a PR.

Can do!

@jbaxleyiii are you still interested in this? should be a relatively quick PR.

馃敂 ping ... 馃槵

@helfer somehow I missed this notification! I'll open a PR today!

No worries, if you're busy, I think someone else would be happy to do it! I'll label it as help wanted, but you can of course still do it if you like!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfaproject picture alfaproject  路  4Comments

tonyxiao picture tonyxiao  路  4Comments

brennantaylor picture brennantaylor  路  4Comments

stubailo picture stubailo  路  3Comments

sebas5384 picture sebas5384  路  4Comments