Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

Always return null #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Always return null #133

wants to merge 1 commit into from

Conversation

peggyrayzis
Copy link
Contributor

GraphQL servers never return undefined, always null. We need to also return null from resolvers without a return value to avoid warnings in Apollo Client.

@@ -57,7 +57,7 @@ export const withClientState = (
resolvers[(rootValue as any).__typename || type][
info.resultKey || fieldName
];
if (resolve) return resolve(rootValue, args, context, info);
if (resolve) return resolve(rootValue, args, context, info) || null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a check for only undefined, because the resolver might return 0 or false by design.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what if it's an async resolver? A promise will always be truthy, even if it resolves to undefined.

@fbartho
Copy link
Contributor

fbartho commented Jan 7, 2018

Hey @peggyrayzis -- I think this PR is still needed (-- do you concur?), but @jamiter made some good points. Is this something you're coming back to? Or would you like someone to collaborate on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants