relay-runtime 1.3.0 → 1.5.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/LICENSE +16 -26
- package/index.js +3 -6
- package/lib/ConvertToExecuteFunction.js +73 -0
- package/lib/RelayConcreteNode.js +31 -14
- package/lib/RelayConcreteVariables.js +11 -6
- package/lib/RelayConnectionHandler.js +2 -4
- package/lib/RelayConnectionInterface.js +3 -5
- package/lib/RelayCore.js +4 -6
- package/lib/RelayDataLoader.js +2 -4
- package/lib/RelayDeclarativeMutationConfig.js +316 -0
- package/lib/RelayDefaultHandleKey.js +2 -4
- package/lib/RelayDefaultHandlerProvider.js +2 -4
- package/lib/RelayError.js +2 -6
- package/lib/RelayInMemoryRecordSource.js +2 -4
- package/lib/RelayInternalTypes.js +2 -5
- package/lib/RelayInternals.js +2 -5
- package/lib/RelayMarkSweepStore.js +22 -5
- package/lib/RelayMetricsRecorder.js +9 -9
- package/lib/RelayMockRenderer.js +3 -8
- package/lib/RelayModernEnvironment.js +120 -135
- package/lib/RelayModernFragmentSpecResolver.js +81 -55
- package/lib/RelayModernGraphQLTag.js +8 -17
- package/lib/RelayModernOperationSelector.js +8 -8
- package/lib/RelayModernRecord.js +8 -8
- package/lib/RelayModernSelector.js +54 -43
- package/lib/RelayNetwork.js +9 -11
- package/lib/RelayNetworkDebug.js +4 -7
- package/lib/RelayNetworkLogger.js +2 -4
- package/lib/RelayNetworkLoggerTransaction.js +18 -20
- package/lib/RelayNetworkTypes.js +2 -4
- package/lib/RelayObservable.js +193 -120
- package/lib/RelayProfiler.js +7 -7
- package/lib/RelayPublishQueue.js +17 -9
- package/lib/RelayQueryCaching.js +2 -5
- package/lib/RelayQueryResponseCache.js +3 -5
- package/lib/RelayReader.js +18 -8
- package/lib/RelayRecordProxy.js +12 -11
- package/lib/RelayRecordSourceMutator.js +9 -9
- package/lib/RelayRecordSourceProxy.js +15 -13
- package/lib/RelayRecordSourceSelectorProxy.js +2 -4
- package/lib/RelayRecordState.js +2 -4
- package/lib/RelayReferenceMarker.js +2 -4
- package/lib/RelayResponseNormalizer.js +34 -25
- package/lib/RelayRuntime.js +25 -14
- package/lib/RelayRuntimeTypes.js +22 -0
- package/lib/RelayShallowMock.js +4 -7
- package/lib/RelayStoreTypes.js +2 -4
- package/lib/RelayStoreUtils.js +66 -26
- package/lib/RelayTaskQueue.js +2 -5
- package/lib/RelayTypes.js +2 -5
- package/lib/RelayViewerHandler.js +4 -5
- package/lib/applyRelayModernOptimisticMutation.js +9 -8
- package/lib/cloneRelayHandleSourceField.js +4 -11
- package/lib/commitLocalUpdate.js +2 -4
- package/lib/commitRelayModernMutation.js +24 -22
- package/lib/createRelayNetworkLogger.js +25 -27
- package/lib/dedent.js +2 -5
- package/lib/deepFreeze.js +3 -5
- package/lib/deferrableFragmentKey.js +21 -0
- package/lib/fetchRelayModernQuery.js +13 -21
- package/lib/generateRelayClientID.js +2 -4
- package/lib/getRelayHandleKey.js +2 -4
- package/lib/hasOverlappingIDs.js +2 -4
- package/lib/isCompatibleRelayFragmentType.js +2 -5
- package/lib/isPromise.js +2 -5
- package/lib/isRelayModernEnvironment.js +2 -4
- package/lib/isScalarAndEqual.js +3 -5
- package/lib/normalizePayload.js +10 -13
- package/lib/normalizeRelayPayload.js +8 -5
- package/lib/recycleNodesInto.js +2 -4
- package/lib/relayUnstableBatchedUpdates.js +2 -5
- package/lib/relayUnstableBatchedUpdates.native.js +2 -5
- package/lib/requestRelaySubscription.js +20 -34
- package/lib/simpleClone.js +2 -4
- package/lib/stableCopy.js +35 -0
- package/lib/testEditDistance.js +2 -5
- package/lib/throwFailedPromise.js +2 -5
- package/package.json +4 -5
- package/relay-runtime.js +2307 -2665
- package/relay-runtime.min.js +6 -9
- package/ARCHITECTURE.md +0 -232
- package/PATENTS +0 -33
- package/lib/ConvertToObserveFunction.js +0 -39
- package/lib/RelayDebugger.js +0 -199
- package/lib/RelayRecordSourceInspector.js +0 -289
- package/lib/RelayStoreProxyDebugger.js +0 -44
- package/lib/formatStorageKey.js +0 -37
- package/lib/prettyStringify.js +0 -35
- package/lib/setRelayModernMutationConfigs.js +0 -302
- package/lib/stableJSONStringify.js +0 -45
package/lib/isPromise.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @providesModule isPromise
|
|
10
8
|
*
|
|
@@ -13,7 +11,6 @@
|
|
|
13
11
|
|
|
14
12
|
'use strict';
|
|
15
13
|
|
|
16
|
-
// eslint-disable-next-line no-redeclare
|
|
17
14
|
function isPromise(p) {
|
|
18
15
|
return !!p && typeof p.then === 'function';
|
|
19
16
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @providesModule isRelayModernEnvironment
|
|
10
8
|
*
|
package/lib/isScalarAndEqual.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
7
|
* @providesModule isScalarAndEqual
|
|
8
|
+
*
|
|
11
9
|
* @format
|
|
12
10
|
*/
|
|
13
11
|
|
package/lib/normalizePayload.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @providesModule normalizePayload
|
|
10
8
|
*
|
|
@@ -13,22 +11,21 @@
|
|
|
13
11
|
|
|
14
12
|
'use strict';
|
|
15
13
|
|
|
16
|
-
var _extends3 = _interopRequireDefault(require('babel-runtime/helpers/extends'));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
|
19
|
-
|
|
20
14
|
var _require = require('./RelayStoreUtils'),
|
|
21
15
|
ROOT_ID = _require.ROOT_ID;
|
|
22
16
|
|
|
23
|
-
function normalizePayload(
|
|
24
|
-
var
|
|
25
|
-
|
|
17
|
+
function normalizePayload(payload) {
|
|
18
|
+
var operation = payload.operation,
|
|
19
|
+
variables = payload.variables,
|
|
20
|
+
response = payload.response;
|
|
21
|
+
var data = response.data,
|
|
22
|
+
errors = response.errors;
|
|
26
23
|
|
|
27
24
|
if (data != null) {
|
|
28
25
|
return require('./normalizeRelayPayload')({
|
|
29
26
|
dataID: ROOT_ID,
|
|
30
|
-
node: operation
|
|
31
|
-
variables:
|
|
27
|
+
node: operation,
|
|
28
|
+
variables: variables
|
|
32
29
|
}, data, errors, { handleStrippedNulls: true });
|
|
33
30
|
}
|
|
34
31
|
var error = require('./RelayError').create('RelayNetwork', 'No data returned for operation `%s`, got error(s):\n%s\n\nSee the error ' + '`source` property for more information.', operation.name, errors ? errors.map(function (_ref) {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @providesModule normalizeRelayPayload
|
|
10
8
|
*
|
|
@@ -22,10 +20,15 @@ function normalizeRelayPayload(selector, payload, errors) {
|
|
|
22
20
|
|
|
23
21
|
var source = new (require('./RelayInMemoryRecordSource'))();
|
|
24
22
|
source.set(ROOT_ID, require('./RelayModernRecord').create(ROOT_ID, ROOT_TYPE));
|
|
25
|
-
|
|
23
|
+
|
|
24
|
+
var _RelayResponseNormali = require('./RelayResponseNormalizer').normalize(source, selector, payload, options),
|
|
25
|
+
fieldPayloads = _RelayResponseNormali.fieldPayloads,
|
|
26
|
+
deferrableSelections = _RelayResponseNormali.deferrableSelections;
|
|
27
|
+
|
|
26
28
|
return {
|
|
27
29
|
errors: errors,
|
|
28
30
|
fieldPayloads: fieldPayloads,
|
|
31
|
+
deferrableSelections: deferrableSelections,
|
|
29
32
|
source: source
|
|
30
33
|
};
|
|
31
34
|
}
|
package/lib/recycleNodesInto.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @providesModule recycleNodesInto
|
|
10
8
|
*
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
|
-
* @providesModule relayUnstableBatchedUpdates
|
|
10
7
|
*
|
|
11
8
|
* @format
|
|
12
9
|
*/
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
|
-
* @providesModule relayUnstableBatchedUpdates
|
|
10
7
|
* @format
|
|
11
8
|
*/
|
|
12
9
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @providesModule requestRelaySubscription
|
|
10
8
|
*
|
|
@@ -16,48 +14,36 @@
|
|
|
16
14
|
function requestRelaySubscription(environment, config) {
|
|
17
15
|
var _environment$unstable = environment.unstable_internal,
|
|
18
16
|
createOperationSelector = _environment$unstable.createOperationSelector,
|
|
19
|
-
|
|
17
|
+
getRequest = _environment$unstable.getRequest;
|
|
20
18
|
|
|
21
|
-
var subscription =
|
|
19
|
+
var subscription = getRequest(config.subscription);
|
|
20
|
+
if (subscription.operationKind !== 'subscription') {
|
|
21
|
+
throw new Error('requestRelaySubscription: Must use Subscription operation');
|
|
22
|
+
}
|
|
22
23
|
var configs = config.configs,
|
|
23
24
|
onCompleted = config.onCompleted,
|
|
24
25
|
onError = config.onError,
|
|
25
26
|
onNext = config.onNext,
|
|
26
27
|
variables = config.variables;
|
|
27
|
-
var updater = config.updater;
|
|
28
28
|
|
|
29
29
|
var operation = createOperationSelector(subscription, variables);
|
|
30
30
|
|
|
31
|
-
require('fbjs/lib/warning')(!(updater && configs), 'requestRelaySubscription: Expected only one of `updater` and `configs` to be provided');
|
|
32
|
-
|
|
33
|
-
if (configs) {
|
|
34
|
-
var _setRelayModernMutati = require('./setRelayModernMutationConfigs')(configs, subscription, null /* optimisticUpdater */
|
|
35
|
-
, updater);
|
|
31
|
+
require('fbjs/lib/warning')(!(config.updater && configs), 'requestRelaySubscription: Expected only one of `updater` and `configs` to be provided');
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
onCompleted: onCompleted,
|
|
41
|
-
onError: onError,
|
|
42
|
-
onNext: function (_onNext) {
|
|
43
|
-
function onNext(_x) {
|
|
44
|
-
return _onNext.apply(this, arguments);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
onNext.toString = function () {
|
|
48
|
-
return _onNext.toString();
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return onNext;
|
|
52
|
-
}(function (payload) {
|
|
53
|
-
if (onNext) {
|
|
54
|
-
var snapshot = environment.lookup(operation.fragment);
|
|
55
|
-
onNext(snapshot.data);
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
33
|
+
var _ref = configs ? require('./RelayDeclarativeMutationConfig').convert(configs, subscription, null /* optimisticUpdater */
|
|
34
|
+
, config.updater) : config,
|
|
35
|
+
updater = _ref.updater;
|
|
58
36
|
|
|
37
|
+
return environment.execute({
|
|
38
|
+
operation: operation,
|
|
59
39
|
updater: updater,
|
|
60
|
-
|
|
40
|
+
cacheConfig: { force: true }
|
|
41
|
+
}).map(function () {
|
|
42
|
+
return environment.lookup(operation.fragment).data;
|
|
43
|
+
}).subscribeLegacy({
|
|
44
|
+
onNext: onNext,
|
|
45
|
+
onError: onError,
|
|
46
|
+
onCompleted: onCompleted
|
|
61
47
|
});
|
|
62
48
|
}
|
|
63
49
|
|
package/lib/simpleClone.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
* @providesModule simpleClone
|
|
10
8
|
*
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
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
|
+
* @providesModule stableCopy
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a copy of the provided value, ensuring any nested objects have their
|
|
16
|
+
* keys sorted such that equivalent values would have identical JSON.stringify
|
|
17
|
+
* results.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function stableCopy(value) {
|
|
21
|
+
if (!value || typeof value !== 'object') {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
return value.map(stableCopy);
|
|
26
|
+
}
|
|
27
|
+
var keys = Object.keys(value).sort();
|
|
28
|
+
var stable = {};
|
|
29
|
+
for (var i = 0; i < keys.length; i++) {
|
|
30
|
+
stable[keys[i]] = stableCopy(value[keys[i]]);
|
|
31
|
+
}
|
|
32
|
+
return stable;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = stableCopy;
|
package/lib/testEditDistance.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
|
-
* @providesModule testEditDistance
|
|
10
7
|
*
|
|
11
8
|
* @format
|
|
12
9
|
*
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
3
|
*
|
|
5
|
-
* This source code is licensed under the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
7
|
*
|
|
10
|
-
* @providesModule throwFailedPromise
|
|
11
8
|
* @format
|
|
12
9
|
*/
|
|
13
10
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relay-runtime",
|
|
3
3
|
"description": "A core runtime for building GraphQL-driven applications.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
7
7
|
"relay"
|
|
8
8
|
],
|
|
9
|
-
"license": "
|
|
9
|
+
"license": "MIT",
|
|
10
10
|
"homepage": "https://facebook.github.io/relay/",
|
|
11
11
|
"bugs": "https://github.com/facebook/relay/issues",
|
|
12
12
|
"repository": "facebook/relay",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"babel-runtime": "^6.23.0",
|
|
15
|
-
"fbjs": "^0.8.
|
|
16
|
-
"relay-debugger-react-native-runtime": "^0.0.9"
|
|
15
|
+
"fbjs": "^0.8.14"
|
|
17
16
|
},
|
|
18
17
|
"peerDependencies": {
|
|
19
|
-
"relay-compiler": "1.
|
|
18
|
+
"relay-compiler": "1.5.0"
|
|
20
19
|
}
|
|
21
20
|
}
|