Skip to content

Commit

Permalink
Use ModuleImport module providers in runtime
Browse files Browse the repository at this point in the history
Reviewed By: voideanvalue

Differential Revision: D38007238

fbshipit-source-id: b405e4c122e365f46371f1896f48d230cb3a728f
  • Loading branch information
tyao1 authored and facebook-github-bot committed Jul 25, 2022
1 parent 3c94dec commit 4d92104
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/relay-runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export type {
NormalizationLinkedHandle,
NormalizationLocalArgumentDefinition,
NormalizationModuleImport,
NormalizationRootNode,
NormalizationScalarField,
NormalizationSelection,
NormalizationSplitOperation,
Expand Down
6 changes: 4 additions & 2 deletions packages/relay-runtime/store/RelayResponseNormalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,16 @@ class RelayResponseNormalizer {
);
const typeName: string = RelayModernRecord.getType(record);
const componentKey = getModuleComponentKey(moduleImport.documentName);
const componentReference = data[componentKey];
const componentReference =
moduleImport.componentModuleProvider || data[componentKey];
RelayModernRecord.setValue(
record,
componentKey,
componentReference ?? null,
);
const operationKey = getModuleOperationKey(moduleImport.documentName);
const operationReference = data[operationKey];
const operationReference =
moduleImport.operationModuleProvider || data[operationKey];
RelayModernRecord.setValue(
record,
operationKey,
Expand Down
9 changes: 9 additions & 0 deletions packages/relay-runtime/util/NormalizationNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'use strict';

import type {ConcreteRequest} from './RelayConcreteNode';
import type {JSResourceReference} from 'JSResourceReference';

/**
* Represents a single operation used to processing and normalize runtime
Expand Down Expand Up @@ -114,6 +115,14 @@ export type NormalizationModuleImport = {
+documentName: string,
+fragmentPropName: string,
+fragmentName: string,
+componentModuleProvider?: () =>
| mixed
| Promise<mixed>
| JSResourceReference<mixed>,
+operationModuleProvider?: () =>
| NormalizationRootNode
| Promise<NormalizationRootNode>
| JSResourceReference<NormalizationRootNode>,
};

export type NormalizationListValueArgument = {
Expand Down

0 comments on commit 4d92104

Please sign in to comment.