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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/apollo-link-state/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change log

### vNEXT
### vNext
- If a resolver doesn't have a return value, default to null

### 0.3.0
- BREAKING: Changed `withClientState` API to take a config object with `resolvers`, `defaults`, and `cache` properties: [#132](https://github.com/apollographql/apollo-link-state/pull/132)
- Fix overriding fragment parent's __typename: [#131](https://github.com/apollographql/apollo-link-state/pull/131)

Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link-state/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apollo-link-state",
"version": "0.3.0",
"version": "0.3.1",
"description": "An easy way to manage local state with Apollo Link",
"author": "James Baxley <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-link-state/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

};

return new Observable(observer => {
Expand Down