Skip to content

Commit

Permalink
Cleanup type for fragment args on @inline fragments
Browse files Browse the repository at this point in the history
Reviewed By: alunyov

Differential Revision: D37330015

fbshipit-source-id: 90d3b822ad5cbeec16d8fc9fc6bc2626331af363
  • Loading branch information
captbaritone authored and facebook-github-bot committed Jul 6, 2022
1 parent bb6cd90 commit 90c2ed6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
28 changes: 12 additions & 16 deletions packages/relay-runtime/store/RelayReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,22 +1116,18 @@ class RelayReader {

const parentVariables = this._variables;

// We only want to update `this._variables` if we have compiler artifacts that support it.
// Until we've rolled out the compiler portion of this change, we need to check at runtime.
if (fragmentSpreadOrFragment.argumentDefinitions != null) {
// If the inline fragment spread has arguments, we need to temporarily
// switch this._variables to include the fragment spread's arguments
// for the duration of its traversal.
const argumentVariables = fragmentSpreadOrFragment.args
? getArgumentValues(fragmentSpreadOrFragment.args, this._variables)
: {};

this._variables = RelayConcreteVariables.getFragmentVariables(
fragmentSpreadOrFragment,
this._owner.variables,
argumentVariables,
);
}
// If the inline fragment spread has arguments, we need to temporarily
// switch this._variables to include the fragment spread's arguments
// for the duration of its traversal.
const argumentVariables = fragmentSpreadOrFragment.args
? getArgumentValues(fragmentSpreadOrFragment.args, this._variables)
: {};

this._variables = RelayConcreteVariables.getFragmentVariables(
fragmentSpreadOrFragment,
this._owner.variables,
argumentVariables,
);

this._traverseSelections(
fragmentSpreadOrFragment.selections,
Expand Down
6 changes: 2 additions & 4 deletions packages/relay-runtime/util/ReaderNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ export type ReaderInlineDataFragmentSpread = {
+kind: 'InlineDataFragmentSpread',
+name: string,
+selections: $ReadOnlyArray<ReaderSelection>,
// TODO: T123948544 Mark both of these as non-optional once the compiler
// changes have rolled out.
+args?: ?$ReadOnlyArray<ReaderArgument>,
+argumentDefinitions?: $ReadOnlyArray<ReaderArgumentDefinition>,
+args: ?$ReadOnlyArray<ReaderArgument>,
+argumentDefinitions: $ReadOnlyArray<ReaderArgumentDefinition>,
};

export type ReaderFragment = {
Expand Down

0 comments on commit 90c2ed6

Please sign in to comment.