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

Refactor queries to allow for cascaded partial results #59

Merged
merged 18 commits into from
Sep 4, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix assumed null for cache resolvers
kitten committed Sep 4, 2019
commit 4573390d287dc84155798b5022d31e0f1ba2aadb
14 changes: 9 additions & 5 deletions src/operations/query.ts
Original file line number Diff line number Diff line change
@@ -201,11 +201,15 @@ const readSelection = (
ctx
);

const isNull = resolverValue === undefined || resolverValue === null;
// When we have a schema we check for a user's resolver whether the field is nullable
// Otherwise we trust the resolver and assume that it is
if (node.selectionSet === undefined || isNull) {
dataFieldValue = isNull ? undefined : resolverValue;
if (node.selectionSet === undefined) {
// When we have a schema we check for a user's resolver whether the field is nullable
// Otherwise we trust the resolver and assume that it is
const isNull = resolverValue === undefined || resolverValue === null;
if (isNull && schemaPredicates !== undefined) {
dataFieldValue = undefined;
} else {
dataFieldValue = isNull ? null : resolverValue;
}
} else {
// When it has a selection set we are resolving an entity with a
// subselection. This can either be a list or an object.