react-relay 2.0.0-rc.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/lib/ReactRelayContext.js +6 -3
- package/lib/ReactRelayFragmentContainer.js +48 -46
- package/lib/ReactRelayFragmentMockRenderer.js +5 -1
- package/lib/ReactRelayPaginationContainer.js +102 -68
- package/lib/ReactRelayQueryFetcher.js +54 -28
- package/lib/ReactRelayQueryRenderer.js +28 -20
- package/lib/ReactRelayRefetchContainer.js +70 -58
- package/lib/ReactRelayTestMocker.js +56 -43
- package/lib/ReactRelayTypes.js +1 -1
- package/lib/RelayContext.js +8 -2
- package/lib/assertFragmentMap.js +9 -7
- package/lib/buildReactRelayContainer.js +32 -23
- package/lib/index.js +41 -0
- package/lib/isRelayEnvironment.js +1 -1
- package/lib/isRelayVariables.js +1 -1
- package/lib/readContext.js +7 -4
- package/package.json +4 -4
- package/react-relay.js +2 -2
- package/react-relay.min.js +2 -2
- package/classic.js +0 -10
- package/compat.js +0 -10
- package/lib/ConcreteQuery.js +0 -10
- package/lib/GraphQLQueryRunner.js +0 -264
- package/lib/GraphQLRange.js +0 -1124
- package/lib/GraphQLSegment.js +0 -743
- package/lib/GraphQLStoreChangeEmitter.js +0 -141
- package/lib/GraphQLStoreQueryResolver.js +0 -288
- package/lib/GraphQLStoreRangeUtils.js +0 -126
- package/lib/QueryBuilder.js +0 -228
- package/lib/ReactRelayClassicExports.js +0 -29
- package/lib/ReactRelayCompatContainerBuilder.js +0 -175
- package/lib/ReactRelayCompatPublic.js +0 -28
- package/lib/ReactRelayContainerProfiler.js +0 -30
- package/lib/ReactRelayFragmentContainer-flowtest.js +0 -201
- package/lib/ReactRelayPaginationContainer-flowtest.js +0 -213
- package/lib/ReactRelayPublic.js +0 -29
- package/lib/ReactRelayRefetchContainer-flowtest.js +0 -191
- package/lib/RelayCacheProcessor.js +0 -196
- package/lib/RelayChangeTracker.js +0 -83
- package/lib/RelayClassicContainerUtils.js +0 -49
- package/lib/RelayClassicCore.js +0 -34
- package/lib/RelayClassicRecordState.js +0 -31
- package/lib/RelayCompatContainer.js +0 -25
- package/lib/RelayCompatEnvironment.js +0 -27
- package/lib/RelayCompatMutations.js +0 -133
- package/lib/RelayCompatPaginationContainer.js +0 -27
- package/lib/RelayCompatRefetchContainer.js +0 -27
- package/lib/RelayCompatTypes.js +0 -10
- package/lib/RelayContainer.js +0 -889
- package/lib/RelayContainerComparators.js +0 -75
- package/lib/RelayContainerProxy.js +0 -21
- package/lib/RelayDefaultNetworkLayer.js +0 -192
- package/lib/RelayEnvironment.js +0 -449
- package/lib/RelayEnvironmentTypes.js +0 -10
- package/lib/RelayFetchMode.js +0 -17
- package/lib/RelayFragmentPointer.js +0 -161
- package/lib/RelayFragmentReference.js +0 -249
- package/lib/RelayFragmentSpecResolver.js +0 -305
- package/lib/RelayGraphQLMutation.js +0 -288
- package/lib/RelayGraphQLTag.js +0 -42
- package/lib/RelayInternalTypes.js +0 -15
- package/lib/RelayInternals.js +0 -24
- package/lib/RelayMetaRoute.js +0 -35
- package/lib/RelayMockRenderer.js +0 -71
- package/lib/RelayModern-flowtest.js +0 -342
- package/lib/RelayModernFlowtest_badref.graphql.js +0 -10
- package/lib/RelayModernFlowtest_notref.graphql.js +0 -10
- package/lib/RelayModernFlowtest_user.graphql.js +0 -10
- package/lib/RelayModernFlowtest_users.graphql.js +0 -10
- package/lib/RelayMutation.js +0 -322
- package/lib/RelayMutationDebugPrinter.js +0 -47
- package/lib/RelayMutationQuery.js +0 -558
- package/lib/RelayMutationQueue.js +0 -530
- package/lib/RelayMutationRequest.js +0 -103
- package/lib/RelayMutationTracker.js +0 -113
- package/lib/RelayMutationTransaction.js +0 -92
- package/lib/RelayMutationTransactionStatus.js +0 -55
- package/lib/RelayNetworkDebug.js +0 -131
- package/lib/RelayNetworkLayer.js +0 -185
- package/lib/RelayNodeInterface.js +0 -104
- package/lib/RelayOperationDescriptor.js +0 -40
- package/lib/RelayOptimisticMutationUtils.js +0 -208
- package/lib/RelayPendingQueryTracker.js +0 -166
- package/lib/RelayPropTypes.js +0 -57
- package/lib/RelayPublic.js +0 -44
- package/lib/RelayQL.js +0 -128
- package/lib/RelayQuery.js +0 -1584
- package/lib/RelayQueryCaching.js +0 -33
- package/lib/RelayQueryConfig.js +0 -58
- package/lib/RelayQueryPath.js +0 -204
- package/lib/RelayQueryRequest.js +0 -103
- package/lib/RelayQueryTracker.js +0 -86
- package/lib/RelayQueryTransform.js +0 -91
- package/lib/RelayQueryVisitor.js +0 -93
- package/lib/RelayQueryWriter.js +0 -573
- package/lib/RelayReadyState.js +0 -83
- package/lib/RelayReadyStateRenderer.js +0 -145
- package/lib/RelayRecord.js +0 -75
- package/lib/RelayRecordStatusMap.js +0 -57
- package/lib/RelayRecordStore.js +0 -433
- package/lib/RelayRecordWriter.js +0 -601
- package/lib/RelayRefQueryDescriptor.js +0 -27
- package/lib/RelayRenderer.js +0 -268
- package/lib/RelayRootContainer.js +0 -125
- package/lib/RelayRoute.js +0 -92
- package/lib/RelayRouteFragment.js +0 -44
- package/lib/RelaySelector.js +0 -201
- package/lib/RelayShallowMock.js +0 -69
- package/lib/RelayStaticContainer.js +0 -38
- package/lib/RelayStore.js +0 -12
- package/lib/RelayStoreConstants.js +0 -20
- package/lib/RelayStoreData.js +0 -660
- package/lib/RelayTaskQueue.js +0 -189
- package/lib/RelayTypes.js +0 -13
- package/lib/RelayVariable.js +0 -32
- package/lib/RelayVariables.js +0 -92
- package/lib/buildRQL.js +0 -160
- package/lib/callsFromGraphQL.js +0 -74
- package/lib/callsToGraphQL.js +0 -34
- package/lib/checkRelayQueryData.js +0 -250
- package/lib/createRelayQuery.js +0 -17
- package/lib/dedent.js +0 -49
- package/lib/diffRelayQuery.js +0 -757
- package/lib/directivesToGraphQL.js +0 -39
- package/lib/filterRelayQuery.js +0 -29
- package/lib/findRelayQueryLeaves.js +0 -293
- package/lib/flattenRelayQuery.js +0 -121
- package/lib/flattenSplitRelayQueries.js +0 -44
- package/lib/forEachRootCallArg.js +0 -40
- package/lib/fromGraphQL.js +0 -48
- package/lib/generateClientEdgeID.js +0 -22
- package/lib/generateClientID.js +0 -27
- package/lib/generateConcreteFragmentID.js +0 -30
- package/lib/generateForceIndex.js +0 -24
- package/lib/generateRQLFieldAlias.js +0 -39
- package/lib/getRangeBehavior.js +0 -58
- package/lib/getRelayQueries.js +0 -83
- package/lib/intersectRelayQuery.js +0 -149
- package/lib/isClassicRelayContext.js +0 -20
- package/lib/isClassicRelayEnvironment.js +0 -20
- package/lib/isCompatibleRelayFragmentType.js +0 -27
- package/lib/isRelayContainer.js +0 -16
- package/lib/makeLegacyStringishComponentRef.js +0 -52
- package/lib/printRelayOSSQuery.js +0 -329
- package/lib/printRelayQuery.js +0 -26
- package/lib/rangeOperationToMetadataKey.js +0 -25
- package/lib/readRelayQueryData.js +0 -551
- package/lib/relayUnstableBatchedUpdates.js +0 -12
- package/lib/relayUnstableBatchedUpdates.native.js +0 -11
- package/lib/restoreRelayCacheData.js +0 -188
- package/lib/serializeRelayQueryCall.js +0 -42
- package/lib/splitDeferredRelayQueries.js +0 -298
- package/lib/stableStringify.js +0 -85
- package/lib/testEditDistance.js +0 -112
- package/lib/throwFailedPromise.js +0 -26
- package/lib/toGraphQL.js +0 -94
- package/lib/transformRelayQueryPayload.js +0 -145
- package/lib/validateMutationConfig.js +0 -117
- package/lib/validateRelayReadQuery.js +0 -112
- package/lib/writeRelayQueryPayload.js +0 -44
- package/lib/writeRelayUpdatePayload.js +0 -513
- package/react-relay-classic.js +0 -4
- package/react-relay-classic.min.js +0 -9
- package/react-relay-compat.js +0 -4
- package/react-relay-compat.min.js +0 -9
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* strict-local
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*
|
|
15
|
-
* Keeps track of records that have been created or updated; used primarily to
|
|
16
|
-
* record changes during the course of a `write` operation.
|
|
17
|
-
*/
|
|
18
|
-
var RelayChangeTracker =
|
|
19
|
-
/*#__PURE__*/
|
|
20
|
-
function () {
|
|
21
|
-
function RelayChangeTracker() {
|
|
22
|
-
this._created = {};
|
|
23
|
-
this._updated = {};
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Record the creation of a record.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _proto = RelayChangeTracker.prototype;
|
|
31
|
-
|
|
32
|
-
_proto.createID = function createID(recordID) {
|
|
33
|
-
this._created[recordID] = true;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Record an update to a record.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
_proto.updateID = function updateID(recordID) {
|
|
41
|
-
if (!this._created.hasOwnProperty(recordID)) {
|
|
42
|
-
this._updated[recordID] = true;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Determine if the record has any changes (was created or updated).
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_proto.hasChange = function hasChange(recordID) {
|
|
51
|
-
return !!(this._updated[recordID] || this._created[recordID]);
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Determine if the record was created.
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_proto.isNewRecord = function isNewRecord(recordID) {
|
|
59
|
-
return !!this._created[recordID];
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Get the ids of records that were created/updated.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
_proto.getChangeSet = function getChangeSet() {
|
|
67
|
-
if (process.env.NODE_ENV !== "production") {
|
|
68
|
-
return {
|
|
69
|
-
created: Object.freeze(this._created),
|
|
70
|
-
updated: Object.freeze(this._updated)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
created: this._created,
|
|
76
|
-
updated: this._updated
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
return RelayChangeTracker;
|
|
81
|
-
}();
|
|
82
|
-
|
|
83
|
-
module.exports = RelayChangeTracker;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*
|
|
14
|
-
* Helper for checking if this is a React Component
|
|
15
|
-
* created with React.Component or React.createClass().
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function isReactComponent(component) {
|
|
19
|
-
if (component == null) {
|
|
20
|
-
return false;
|
|
21
|
-
} // React class component or createClass()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (typeof component.prototype === 'object' && component.prototype && component.prototype.isReactComponent) {
|
|
25
|
-
return true;
|
|
26
|
-
} // @TODO (T28161354) Remove this check
|
|
27
|
-
// React.forwardRef component
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if ( // $FlowFixMe: add 'symbol' as a valid return value for typeof
|
|
31
|
-
typeof component.$$typeof === 'symbol' && // ES6 symbol
|
|
32
|
-
typeof component.render === 'function') {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function getReactComponent(Component) {
|
|
40
|
-
if (isReactComponent(Component)) {
|
|
41
|
-
return Component;
|
|
42
|
-
} else {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = {
|
|
48
|
-
getReactComponent: getReactComponent
|
|
49
|
-
};
|
package/lib/RelayClassicCore.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* strict-local
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
function createFragmentSpecResolver(context, containerName, fragments, props, callback) {
|
|
13
|
-
return new (require("./RelayFragmentSpecResolver"))(context, fragments, props, callback);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The classic implementation of the `RelayCore` interface defined in
|
|
17
|
-
* `RelayEnvironmentTypes`.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
areEqualSelectors: require("./RelaySelector").areEqualSelectors,
|
|
23
|
-
createFragmentSpecResolver: createFragmentSpecResolver,
|
|
24
|
-
createOperationDescriptor: require("./RelayOperationDescriptor").createOperationDescriptor,
|
|
25
|
-
getDataIDsFromObject: require("./RelaySelector").getDataIDsFromObject,
|
|
26
|
-
getFragment: require("./RelayGraphQLTag").getClassicFragment,
|
|
27
|
-
getRequest: require("./RelayGraphQLTag").getClassicOperation,
|
|
28
|
-
getSelector: require("./RelaySelector").getSelector,
|
|
29
|
-
getSelectorList: require("./RelaySelector").getSelectorList,
|
|
30
|
-
getSelectorsFromObject: require("./RelaySelector").getSelectorsFromObject,
|
|
31
|
-
getVariablesFromObject: require("./RelaySelector").getVariablesFromObject,
|
|
32
|
-
isFragment: require("./RelayGraphQLTag").isClassicFragment,
|
|
33
|
-
isRequest: require("./RelayGraphQLTag").isClassicOperation
|
|
34
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* strict
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
var RelayClassicRecordState = {
|
|
13
|
-
/**
|
|
14
|
-
* Record exists (either fetched from the server or produced by a local,
|
|
15
|
-
* optimistic update).
|
|
16
|
-
*/
|
|
17
|
-
EXISTENT: 'EXISTENT',
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Record is known not to exist (either as the result of a mutation, or
|
|
21
|
-
* because the server returned `null` when queried for the record).
|
|
22
|
-
*/
|
|
23
|
-
NONEXISTENT: 'NONEXISTENT',
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Record State is unknown because it has not yet been fetched from the
|
|
27
|
-
* server.
|
|
28
|
-
*/
|
|
29
|
-
UNKNOWN: 'UNKNOWN'
|
|
30
|
-
};
|
|
31
|
-
module.exports = RelayClassicRecordState;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Wrap the basic `createContainer()` function with logic to adapt to the
|
|
14
|
-
* `context.relay.environment` in which it is rendered. Specifically, the
|
|
15
|
-
* extraction of the environment-specific version of fragments in the
|
|
16
|
-
* `fragmentSpec` is memoized once per environment, rather than once per
|
|
17
|
-
* instance of the container constructed/rendered.
|
|
18
|
-
*/
|
|
19
|
-
function createContainer(Component, fragmentSpec, compatModuleName) {
|
|
20
|
-
return require("./ReactRelayCompatContainerBuilder").buildCompatContainer(Component, fragmentSpec, require("./ReactRelayFragmentContainer").createContainerWithFragments, compatModuleName);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
createContainer: createContainer
|
|
25
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
function getRelayModernEnvironment(environment) {
|
|
13
|
-
if (require("relay-runtime").isRelayModernEnvironment(environment)) {
|
|
14
|
-
return environment;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getRelayClassicEnvironment(environment) {
|
|
19
|
-
if (require("./isClassicRelayEnvironment")(environment)) {
|
|
20
|
-
return environment;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
getRelayClassicEnvironment: getRelayClassicEnvironment,
|
|
26
|
-
getRelayModernEnvironment: getRelayModernEnvironment
|
|
27
|
-
};
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
var injectedCompatLoggingFunction = function injectedCompatLoggingFunction() {};
|
|
13
|
-
|
|
14
|
-
function injectCompatLoggingFunction(loggingFunction) {
|
|
15
|
-
injectedCompatLoggingFunction = loggingFunction;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function commitUpdate(environment, config) {
|
|
19
|
-
var moduleName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unknown';
|
|
20
|
-
|
|
21
|
-
var modernEnvironment = require("./RelayCompatEnvironment").getRelayModernEnvironment(environment);
|
|
22
|
-
|
|
23
|
-
if (modernEnvironment) {
|
|
24
|
-
injectedCompatLoggingFunction(moduleName, true);
|
|
25
|
-
return require("relay-runtime").commitMutation(modernEnvironment, config);
|
|
26
|
-
} else {
|
|
27
|
-
var classicEnvironment = require("./RelayCompatEnvironment").getRelayClassicEnvironment(environment);
|
|
28
|
-
|
|
29
|
-
!classicEnvironment ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayCompatMutations: Expected an object that conforms to the ' + '`RelayEnvironmentInterface`, got `%s`.', environment) : require("fbjs/lib/invariant")(false) : void 0;
|
|
30
|
-
injectedCompatLoggingFunction(moduleName, false);
|
|
31
|
-
return commitRelayClassicMutation( // getRelayClassicEnvironment returns a RelayEnvironmentInterface
|
|
32
|
-
// (classic APIs), but we need the modern APIs on old core here.
|
|
33
|
-
classicEnvironment, config);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function applyUpdate(environment, config) {
|
|
38
|
-
var moduleName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unknown';
|
|
39
|
-
|
|
40
|
-
var modernEnvironment = require("./RelayCompatEnvironment").getRelayModernEnvironment(environment);
|
|
41
|
-
|
|
42
|
-
if (modernEnvironment) {
|
|
43
|
-
injectedCompatLoggingFunction(moduleName, true);
|
|
44
|
-
return require("relay-runtime").applyOptimisticMutation(modernEnvironment, config);
|
|
45
|
-
} else {
|
|
46
|
-
var classicEnvironment = require("./RelayCompatEnvironment").getRelayClassicEnvironment(environment);
|
|
47
|
-
|
|
48
|
-
!classicEnvironment ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayCompatMutations: Expected an object that conforms to the ' + '`RelayEnvironmentInterface`, got `%s`.', environment) : require("fbjs/lib/invariant")(false) : void 0;
|
|
49
|
-
injectedCompatLoggingFunction(moduleName, false);
|
|
50
|
-
return applyRelayClassicMutation( // getRelayClassicEnvironment returns a RelayEnvironmentInterface
|
|
51
|
-
// (classic APIs), but we need the modern APIs on old core here.
|
|
52
|
-
classicEnvironment, config);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function commitRelayClassicMutation(environment, _ref) {
|
|
57
|
-
var configs = _ref.configs,
|
|
58
|
-
mutation = _ref.mutation,
|
|
59
|
-
onCompleted = _ref.onCompleted,
|
|
60
|
-
onError = _ref.onError,
|
|
61
|
-
optimisticResponse = _ref.optimisticResponse,
|
|
62
|
-
variables = _ref.variables,
|
|
63
|
-
uploadables = _ref.uploadables;
|
|
64
|
-
var getRequest = environment.unstable_internal.getRequest;
|
|
65
|
-
var operation = getRequest(mutation); // TODO: remove this check after we fix flow.
|
|
66
|
-
|
|
67
|
-
if (typeof optimisticResponse === 'function') {
|
|
68
|
-
process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'RelayCompatMutations: Expected `optimisticResponse` to be an object, ' + 'received a function.') : void 0;
|
|
69
|
-
optimisticResponse = optimisticResponse();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (optimisticResponse) {
|
|
73
|
-
optimisticResponse = validateOptimisticResponse(operation, optimisticResponse);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return environment.sendMutation({
|
|
77
|
-
configs: configs || [],
|
|
78
|
-
operation: operation,
|
|
79
|
-
onCompleted: onCompleted,
|
|
80
|
-
onError: onError,
|
|
81
|
-
optimisticResponse: optimisticResponse,
|
|
82
|
-
variables: variables,
|
|
83
|
-
uploadables: uploadables
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function applyRelayClassicMutation(environment, _ref2) {
|
|
88
|
-
var configs = _ref2.configs,
|
|
89
|
-
mutation = _ref2.mutation,
|
|
90
|
-
optimisticResponse = _ref2.optimisticResponse,
|
|
91
|
-
variables = _ref2.variables;
|
|
92
|
-
var getRequest = environment.unstable_internal.getRequest;
|
|
93
|
-
var operation = getRequest(mutation);
|
|
94
|
-
|
|
95
|
-
if (operation.operation !== 'mutation') {
|
|
96
|
-
throw new Error('RelayCompatMutations: Expected mutation operation');
|
|
97
|
-
} // RelayClassic can't update anything without response.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (!optimisticResponse) {
|
|
101
|
-
return {
|
|
102
|
-
dispose: function dispose() {}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
optimisticResponse = validateOptimisticResponse(operation, optimisticResponse);
|
|
107
|
-
return environment.applyMutation({
|
|
108
|
-
configs: configs || [],
|
|
109
|
-
operation: operation,
|
|
110
|
-
optimisticResponse: optimisticResponse,
|
|
111
|
-
variables: variables
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function validateOptimisticResponse(operation, optimisticResponse) {
|
|
116
|
-
if (operation.node.kind === 'Mutation' && operation.node.calls && operation.node.calls.length === 1) {
|
|
117
|
-
var mutationRoot = operation.node.calls[0].name;
|
|
118
|
-
|
|
119
|
-
if (optimisticResponse[mutationRoot]) {
|
|
120
|
-
return optimisticResponse[mutationRoot];
|
|
121
|
-
} else {
|
|
122
|
-
process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(false, 'RelayCompatMutations: Expected result from `optimisticResponse`' + 'to contain the mutation name `%s` as a property, got `%s`', mutationRoot, optimisticResponse) : void 0;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return optimisticResponse;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = {
|
|
130
|
-
applyUpdate: applyUpdate,
|
|
131
|
-
commitUpdate: commitUpdate,
|
|
132
|
-
injectCompatLoggingFunction: injectCompatLoggingFunction
|
|
133
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Wrap the basic `createContainer()` function with logic to adapt to the
|
|
14
|
-
* `context.relay.environment` in which it is rendered. Specifically, the
|
|
15
|
-
* extraction of the environment-specific version of fragments in the
|
|
16
|
-
* `fragmentSpec` is memoized once per environment, rather than once per
|
|
17
|
-
* instance of the container constructed/rendered.
|
|
18
|
-
*/
|
|
19
|
-
function createContainer(Component, fragmentSpec, connectionConfig, compatModuleName) {
|
|
20
|
-
return require("./ReactRelayCompatContainerBuilder").buildCompatContainer(Component, fragmentSpec, function (ComponentClass, fragments) {
|
|
21
|
-
return require("./ReactRelayPaginationContainer").createContainerWithFragments(ComponentClass, fragments, connectionConfig);
|
|
22
|
-
}, compatModuleName);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
createContainer: createContainer
|
|
27
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @format
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Wrap the basic `createContainer()` function with logic to adapt to the
|
|
14
|
-
* `context.relay.environment` in which it is rendered. Specifically, the
|
|
15
|
-
* extraction of the environment-specific version of fragments in the
|
|
16
|
-
* `fragmentSpec` is memoized once per environment, rather than once per
|
|
17
|
-
* instance of the container constructed/rendered.
|
|
18
|
-
*/
|
|
19
|
-
function createContainer(Component, fragmentSpec, taggedNode, compatModuleName) {
|
|
20
|
-
return require("./ReactRelayCompatContainerBuilder").buildCompatContainer(Component, fragmentSpec, function (ComponentClass, fragments) {
|
|
21
|
-
return require("./ReactRelayRefetchContainer").createContainerWithFragments(ComponentClass, fragments, taggedNode);
|
|
22
|
-
}, compatModuleName);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
createContainer: createContainer
|
|
27
|
-
};
|
package/lib/RelayCompatTypes.js
DELETED