Skip to content

Commit

Permalink
fix(metadata): fix getRefetchMetadata to handle both commonjs and es … (
Browse files Browse the repository at this point in the history
#2875)

Summary:
…modules, fix #2874

this is the same approach of relay-compiler

we could move this to a helper function
Pull Request resolved: #2875

Reviewed By: josephsavona

Differential Revision: D18017687

Pulled By: jstejada

fbshipit-source-id: b7627181a36f5c5a7e6806698cf6efffe860d00c
  • Loading branch information
sibelius authored and Juan Tejada committed Oct 21, 2019
1 parent a3043cf commit 578ce86
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/relay-experimental/getRefetchMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ function getRefetchMetadata(
fragmentNode.name,
);

const refetchableRequest = refetchMetadata.operation;
// handle both commonjs and es modules
const refetchableRequest:
| ConcreteRequest
| string = (refetchMetadata: $FlowFixMe).operation.default
? (refetchMetadata: $FlowFixMe).operation.default
: refetchMetadata.operation;
const fragmentRefPathInResponse = refetchMetadata.fragmentPathInResult;
invariant(
typeof refetchableRequest !== 'string',
Expand Down

0 comments on commit 578ce86

Please sign in to comment.