From 90c2ed6a4c019d9007ea82154849bf227f547adc Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Wed, 6 Jul 2022 12:12:33 -0700 Subject: [PATCH] Cleanup type for fragment args on @inline fragments Reviewed By: alunyov Differential Revision: D37330015 fbshipit-source-id: 90d3b822ad5cbeec16d8fc9fc6bc2626331af363 --- packages/relay-runtime/store/RelayReader.js | 28 +++++++++------------ packages/relay-runtime/util/ReaderNode.js | 6 ++--- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/packages/relay-runtime/store/RelayReader.js b/packages/relay-runtime/store/RelayReader.js index 1db296e5dac6f..be3b4e1217093 100644 --- a/packages/relay-runtime/store/RelayReader.js +++ b/packages/relay-runtime/store/RelayReader.js @@ -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, diff --git a/packages/relay-runtime/util/ReaderNode.js b/packages/relay-runtime/util/ReaderNode.js index 046054e2e3e23..2ab7392e370ec 100644 --- a/packages/relay-runtime/util/ReaderNode.js +++ b/packages/relay-runtime/util/ReaderNode.js @@ -31,10 +31,8 @@ export type ReaderInlineDataFragmentSpread = { +kind: 'InlineDataFragmentSpread', +name: string, +selections: $ReadOnlyArray, - // TODO: T123948544 Mark both of these as non-optional once the compiler - // changes have rolled out. - +args?: ?$ReadOnlyArray, - +argumentDefinitions?: $ReadOnlyArray, + +args: ?$ReadOnlyArray, + +argumentDefinitions: $ReadOnlyArray, }; export type ReaderFragment = {