Skip to content

Commit

Permalink
Fix broken relay-experimental imports; Add Record: RelayModernRecord …
Browse files Browse the repository at this point in the history
…to relay-runtime API (#2847)

Summary:
Suggested fix for #2845
Pull Request resolved: #2847

Test Plan:
- jest/flow
- sync to www, test comet there
- build our packages in local copy of repo, verified that ReactRelayContext was properly added to the `react-relay` package.

{F209078094}

Reviewed By: kassens

Differential Revision: D17366489

Pulled By: jstejada

fbshipit-source-id: 3f1d79af296293d1f38201199c220ffaf1d496f0
  • Loading branch information
babangsund authored and facebook-github-bot committed Sep 13, 2019
1 parent 8319368 commit bf78647
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const builds = [
package: 'react-relay',
exports: {
index: 'index.js',
ReactRelayContext: 'ReactRelayContext.js',
},
bundles: [
{
Expand Down
10 changes: 5 additions & 5 deletions packages/relay-experimental/useRefetchableFragmentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ if (__DEV__) {
fragmentRefPathInResponse: $ReadOnlyArray<string | number>,
environment: IEnvironment,
): ?DebugIDandTypename {
const RelayModernRecord = require('relay-runtime/store/RelayModernRecord');
const {Record} = require('relay-runtime');
const id = memoRefetchVariables?.id;
if (
fragmentRefPathInResponse.length !== 1 ||
Expand All @@ -541,7 +541,7 @@ if (__DEV__) {
}
const recordSource = environment.getStore().getSource();
const record = recordSource.get(id);
const typename = record && RelayModernRecord.getType(record);
const typename = record && Record.getType(record);
if (typename == null) {
return null;
}
Expand All @@ -557,13 +557,13 @@ if (__DEV__) {
fragmentNode: ReaderFragment,
componentDisplayName: string,
): void {
const RelayModernRecord = require('relay-runtime/store/RelayModernRecord');
const {Record} = require('relay-runtime');
if (!previousIDAndType) {
return;
}
const recordSource = environment.getStore().getSource();
const record = recordSource.get(previousIDAndType.id);
const typename = record && RelayModernRecord.getType(record);
const typename = record && Record.getType(record);
if (typename !== previousIDAndType.typename) {
warning(
false,
Expand All @@ -588,7 +588,7 @@ if (__DEV__) {
if (previousIDAndTypename == null) {
return;
}
const {ID_KEY} = require('relay-runtime/store/RelayStoreUtils');
const {ID_KEY} = require('relay-runtime');
// $FlowExpectedError
const resultID = refetchedFragmentRef[ID_KEY];
if (resultID != null && resultID !== previousIDAndTypename.id) {
Expand Down
2 changes: 2 additions & 0 deletions packages/relay-runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const RelayModernEnvironment = require('./store/RelayModernEnvironment');
const RelayModernFragmentOwner = require('./store/RelayModernFragmentOwner');
const RelayModernGraphQLTag = require('./query/RelayModernGraphQLTag');
const RelayModernOperationDescriptor = require('./store/RelayModernOperationDescriptor');
const RelayModernRecord = require('./store/RelayModernRecord');
const RelayModernSelector = require('./store/RelayModernSelector');
const RelayModernStore = require('./store/RelayModernStore');
const RelayNetwork = require('./network/RelayNetwork');
Expand Down Expand Up @@ -221,6 +222,7 @@ module.exports = {
Observable: RelayObservable,
QueryResponseCache: RelayQueryResponseCache,
RecordSource: RelayRecordSource,
Record: RelayModernRecord,
Store: RelayModernStore,

areEqualSelectors: RelayModernSelector.areEqualSelectors,
Expand Down

0 comments on commit bf78647

Please sign in to comment.