-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RelayReader: dont consider data on non-matching types "missing"
Summary: == Motivation == The goal of this stack is to more accurately model GraphQL semantics so that client-side execution matches server-side execution. Specifically, the server has full knowledge of the schema (which types implement which interfaces) and uses this to evaluate or skip type-conditional selections (inline fragments and fragment spreads). Relay doesn't currently have full knowledge of the schema and uses simple rules to decide which type-conditional selections to evaluate, which can result in incorrectly evaluating selections that (per schema/spec) should not be evaluated. There are two cases: 1. Reading fragment spreads where a concrete fragment is spread within an abstract type. Currently Relay cannot distinguish whether the fragment is on a concrete type or not, and always tries to read the fragment. Technically, the fragment shouldn't be evaluated (read) at all. 2. Reading inline fragments. == This Diff == This diff is a follow-up to D21281486 and addresses item 1 above. The previous diff changed fragments to have a `concreteType: ?string` field that tells us whether the fragment has a concrete type or not. In this diff, RelayReader is updated to use that information to ensure that `isMissingData` is considered false whenever we try to read a concrete fragment for an object w a non-matching type. As an example, if the object is a `Page` but the fragment is `on User`, we will always set `isMissingData: false` since the types don't match. This makes sense if you think of `isMissingData` as an abbreviation of `isMissing(Expected)Data`: in these cases no data is actually expected. Reviewed By: jstejada Differential Revision: D21306925 fbshipit-source-id: 4074880487ac94e87b4f586570b83e084837e92c
- Loading branch information
1 parent
e4dd883
commit 11bf467
Showing
3 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters