react-relay 2.0.0-rc.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,213 +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
|
-
var _objectSpread2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/objectSpread"));
|
13
|
-
|
14
|
-
var _taggedTemplateLiteral2 = require("@babel/runtime/helpers/interopRequireDefault")(require("./taggedTemplateLiteral"));
|
15
|
-
|
16
|
-
var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
|
17
|
-
|
18
|
-
var _defineProperty2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/defineProperty"));
|
19
|
-
|
20
|
-
function _templateObject2() {
|
21
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n query ReactRelayPaginationContainerFlowtest_Foo_ViewerQuery(\n $count: Int!\n $cursor: ID\n ) {\n viewer {\n ...Foo_viewer\n }\n }\n "]);
|
22
|
-
|
23
|
-
_templateObject2 = function _templateObject2() {
|
24
|
-
return data;
|
25
|
-
};
|
26
|
-
|
27
|
-
return data;
|
28
|
-
}
|
29
|
-
|
30
|
-
function _templateObject() {
|
31
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n fragment ReactRelayPaginationContainerFlowtest_Foo_viewer on Viewer {\n all_friends(after: $cursor, first: $count) @connection {\n edges {\n node {\n __typename\n }\n }\n }\n }\n "]);
|
32
|
-
|
33
|
-
_templateObject = function _templateObject() {
|
34
|
-
return data;
|
35
|
-
};
|
36
|
-
|
37
|
-
return data;
|
38
|
-
}
|
39
|
-
|
40
|
-
/**
|
41
|
-
* Verifies that normal prop type checking, as well as the methods proxying Relay does, is
|
42
|
-
* type-checked correctly on Relay components.
|
43
|
-
*/
|
44
|
-
|
45
|
-
/* $FlowFixMe(>=0.53.0) This comment suppresses an error
|
46
|
-
* when upgrading Flow's support for React. Common errors found when upgrading
|
47
|
-
* Flow's React support are documented at https://fburl.com/eq7bs81w */
|
48
|
-
var FooComponent =
|
49
|
-
/*#__PURE__*/
|
50
|
-
function (_React$Component) {
|
51
|
-
(0, _inheritsLoose2["default"])(FooComponent, _React$Component);
|
52
|
-
|
53
|
-
function FooComponent() {
|
54
|
-
return _React$Component.apply(this, arguments) || this;
|
55
|
-
}
|
56
|
-
|
57
|
-
var _proto = FooComponent.prototype;
|
58
|
-
|
59
|
-
_proto.getNum = function getNum() {
|
60
|
-
return 42;
|
61
|
-
};
|
62
|
-
|
63
|
-
_proto.render = function render() {
|
64
|
-
var reqLen = this.props.requiredProp.length;
|
65
|
-
var optionalProp = this.props.optionalProp;
|
66
|
-
/** $FlowExpectedError: `optionalProp` might be null **/
|
67
|
-
|
68
|
-
var optionalFoo = this.props.optionalProp.foo;
|
69
|
-
/** $FlowExpectedError: there is no prop `missingProp` **/
|
70
|
-
|
71
|
-
var missing = this.props.missingProp;
|
72
|
-
var defLen = this.props.defaultProp.length; // always a valid string, so no error
|
73
|
-
|
74
|
-
return require("react").createElement("div", null, reqLen && optionalProp && optionalFoo && missing && defLen);
|
75
|
-
};
|
76
|
-
|
77
|
-
return FooComponent;
|
78
|
-
}(require("react").Component); // Note that we must reassign to a new identifier to make sure flow doesn't propogate types without
|
79
|
-
// the relay type definition doing the work.
|
80
|
-
|
81
|
-
|
82
|
-
(0, _defineProperty2["default"])(FooComponent, "defaultProps", {
|
83
|
-
defaultProp: 'default'
|
84
|
-
});
|
85
|
-
|
86
|
-
var Foo = require("./ReactRelayPublic").createPaginationContainer(FooComponent, require("./ReactRelayPublic").graphql(_templateObject()), {
|
87
|
-
direction: 'forward',
|
88
|
-
getConnectionFromProps: function getConnectionFromProps(props) {
|
89
|
-
return props.viewer.all_friends;
|
90
|
-
},
|
91
|
-
getFragmentVariables: function getFragmentVariables(vars, totalCount) {
|
92
|
-
return (0, _objectSpread2["default"])({}, vars, {
|
93
|
-
count: totalCount
|
94
|
-
});
|
95
|
-
},
|
96
|
-
getVariables: function getVariables(props, _ref) {
|
97
|
-
var count = _ref.count,
|
98
|
-
cursor = _ref.cursor;
|
99
|
-
return {
|
100
|
-
after: cursor,
|
101
|
-
count: count
|
102
|
-
};
|
103
|
-
},
|
104
|
-
query: require("./ReactRelayPublic").graphql(_templateObject2())
|
105
|
-
});
|
106
|
-
|
107
|
-
module.exports = {
|
108
|
-
checkMissingProp: function checkMissingProp() {
|
109
|
-
/** $ShouldBeFlowExpectedError: Foo missing `requiredProp` **/
|
110
|
-
return require("react").createElement(Foo, null);
|
111
|
-
},
|
112
|
-
checkMinimalProps: function checkMinimalProps() {
|
113
|
-
// All is well
|
114
|
-
return require("react").createElement(Foo, {
|
115
|
-
requiredProp: "foo"
|
116
|
-
});
|
117
|
-
},
|
118
|
-
checkWrongPropType: function checkWrongPropType() {
|
119
|
-
/** $ShouldBeFlowExpectedError: Foo1 wrong `requiredProp` type, should be string **/
|
120
|
-
return require("react").createElement(Foo, {
|
121
|
-
requiredProp: 17
|
122
|
-
});
|
123
|
-
},
|
124
|
-
checkWrongOptionalType: function checkWrongOptionalType() {
|
125
|
-
/** $ShouldBeFlowExpectedError: Foo wrong `optionalProp` type, should be `{foo: string}` **/
|
126
|
-
return require("react").createElement(Foo, {
|
127
|
-
optionalProp: "wrongType",
|
128
|
-
requiredProp: "foo"
|
129
|
-
});
|
130
|
-
},
|
131
|
-
checkNullOptionalType: function checkNullOptionalType() {
|
132
|
-
/** $ShouldBeFlowExpectedError: Foo `optionalProp` must be omitted or truthy, not null **/
|
133
|
-
return require("react").createElement(Foo, {
|
134
|
-
optionalProp: null,
|
135
|
-
requiredProp: "foo"
|
136
|
-
});
|
137
|
-
},
|
138
|
-
checkWrongDefaultPropType: function checkWrongDefaultPropType() {
|
139
|
-
/** $ShouldBeFlowExpectedError: Foo wrong `defaultProp` type, should be string **/
|
140
|
-
return require("react").createElement(Foo, {
|
141
|
-
defaultProp: false,
|
142
|
-
requiredProp: "foo"
|
143
|
-
});
|
144
|
-
},
|
145
|
-
checkAllPossibleProps: function checkAllPossibleProps() {
|
146
|
-
// All is well
|
147
|
-
return require("react").createElement(Foo, {
|
148
|
-
defaultProp: "bar",
|
149
|
-
optionalProp: {
|
150
|
-
foo: 42
|
151
|
-
},
|
152
|
-
requiredProp: "foo"
|
153
|
-
});
|
154
|
-
},
|
155
|
-
checkMinimalPropSpread: function checkMinimalPropSpread() {
|
156
|
-
// All is well
|
157
|
-
var props = {
|
158
|
-
requiredProp: 'foo'
|
159
|
-
};
|
160
|
-
return require("react").createElement(Foo, props);
|
161
|
-
},
|
162
|
-
checkMissingPropSpread: function checkMissingPropSpread() {
|
163
|
-
var props = {
|
164
|
-
defaultProp: 'foo'
|
165
|
-
};
|
166
|
-
/** $ShouldBeFlowExpectedError: Foo missing `requiredProp` with spread **/
|
167
|
-
|
168
|
-
return require("react").createElement(Foo, props);
|
169
|
-
},
|
170
|
-
checkStaticsAndMethodsProxying: function checkStaticsAndMethodsProxying() {
|
171
|
-
/* $FlowFixMe(>=0.53.0) This comment suppresses an
|
172
|
-
* error when upgrading Flow's support for React. Common errors found when
|
173
|
-
* upgrading Flow's React support are documented at
|
174
|
-
* https://fburl.com/eq7bs81w */
|
175
|
-
var ProxyChecker =
|
176
|
-
/*#__PURE__*/
|
177
|
-
function (_React$PureComponent) {
|
178
|
-
(0, _inheritsLoose2["default"])(ProxyChecker, _React$PureComponent);
|
179
|
-
|
180
|
-
function ProxyChecker() {
|
181
|
-
return _React$PureComponent.apply(this, arguments) || this;
|
182
|
-
}
|
183
|
-
|
184
|
-
var _proto2 = ProxyChecker.prototype;
|
185
|
-
|
186
|
-
_proto2.getString = function getString() {
|
187
|
-
var ok = this._fooRef ? this._fooRef.getNum() : 'default'; // legit
|
188
|
-
|
189
|
-
/** $FlowExpectedError: Foo does not have `missingMethod` **/
|
190
|
-
|
191
|
-
var bad = this._fooRef ? this._fooRef.missingMethod() : 'default';
|
192
|
-
/** $FlowExpectedError: Foo `getNum` gives number, but `getString` assumes string **/
|
193
|
-
|
194
|
-
return bad ? 'not good' : ok;
|
195
|
-
};
|
196
|
-
|
197
|
-
_proto2.render = function render() {
|
198
|
-
var _this = this;
|
199
|
-
|
200
|
-
return require("react").createElement(Foo, {
|
201
|
-
componentRef: function componentRef(ref) {
|
202
|
-
_this._fooRef = ref;
|
203
|
-
},
|
204
|
-
requiredProp: "bar"
|
205
|
-
});
|
206
|
-
};
|
207
|
-
|
208
|
-
return ProxyChecker;
|
209
|
-
}(require("react").PureComponent);
|
210
|
-
|
211
|
-
return require("react").createElement(ProxyChecker, null);
|
212
|
-
}
|
213
|
-
};
|
package/lib/ReactRelayPublic.js
DELETED
@@ -1,29 +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
|
-
* The public interface to React Relay.
|
14
|
-
*/
|
15
|
-
module.exports = {
|
16
|
-
QueryRenderer: require("./ReactRelayQueryRenderer"),
|
17
|
-
MutationTypes: require("relay-runtime").MutationTypes,
|
18
|
-
RangeOperations: require("relay-runtime").RangeOperations,
|
19
|
-
ReactRelayContext: require("./ReactRelayContext"),
|
20
|
-
applyOptimisticMutation: require("relay-runtime").applyOptimisticMutation,
|
21
|
-
commitLocalUpdate: require("relay-runtime").commitLocalUpdate,
|
22
|
-
commitMutation: require("relay-runtime").commitMutation,
|
23
|
-
createFragmentContainer: require("./ReactRelayFragmentContainer").createContainer,
|
24
|
-
createPaginationContainer: require("./ReactRelayPaginationContainer").createContainer,
|
25
|
-
createRefetchContainer: require("./ReactRelayRefetchContainer").createContainer,
|
26
|
-
fetchQuery: require("relay-runtime").fetchQuery,
|
27
|
-
graphql: require("relay-runtime").graphql,
|
28
|
-
requestSubscription: require("relay-runtime").requestSubscription
|
29
|
-
};
|
@@ -1,191 +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
|
-
var _taggedTemplateLiteral2 = require("@babel/runtime/helpers/interopRequireDefault")(require("./taggedTemplateLiteral"));
|
13
|
-
|
14
|
-
var _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
|
15
|
-
|
16
|
-
var _defineProperty2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/defineProperty"));
|
17
|
-
|
18
|
-
function _templateObject2() {
|
19
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n query ReactRelayRefetchContainerFlowtest_Foo_ViewerQuery(\n $count: Int!\n $cursor: ID\n ) {\n viewer {\n ...Foo_viewer\n }\n }\n "]);
|
20
|
-
|
21
|
-
_templateObject2 = function _templateObject2() {
|
22
|
-
return data;
|
23
|
-
};
|
24
|
-
|
25
|
-
return data;
|
26
|
-
}
|
27
|
-
|
28
|
-
function _templateObject() {
|
29
|
-
var data = (0, _taggedTemplateLiteral2["default"])(["\n fragment ReactRelayRefetchContainerFlowtest_Foo_viewer on Viewer {\n all_friends(after: $cursor, first: $count) @connection {\n edges {\n node {\n __typename\n }\n }\n }\n }\n "]);
|
30
|
-
|
31
|
-
_templateObject = function _templateObject() {
|
32
|
-
return data;
|
33
|
-
};
|
34
|
-
|
35
|
-
return data;
|
36
|
-
}
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Verifies that normal prop type checking works correctly on Relay components.
|
40
|
-
*/
|
41
|
-
|
42
|
-
/* $FlowFixMe(>=0.53.0) This comment suppresses an error
|
43
|
-
* when upgrading Flow's support for React. Common errors found when upgrading
|
44
|
-
* Flow's React support are documented at https://fburl.com/eq7bs81w */
|
45
|
-
var FooComponent =
|
46
|
-
/*#__PURE__*/
|
47
|
-
function (_React$Component) {
|
48
|
-
(0, _inheritsLoose2["default"])(FooComponent, _React$Component);
|
49
|
-
|
50
|
-
function FooComponent() {
|
51
|
-
return _React$Component.apply(this, arguments) || this;
|
52
|
-
}
|
53
|
-
|
54
|
-
var _proto = FooComponent.prototype;
|
55
|
-
|
56
|
-
_proto.getNum = function getNum() {
|
57
|
-
return 42;
|
58
|
-
};
|
59
|
-
|
60
|
-
_proto.render = function render() {
|
61
|
-
var reqLen = this.props.requiredProp.length;
|
62
|
-
var optionalProp = this.props.optionalProp;
|
63
|
-
/** $FlowExpectedError: `optionalProp` might be null **/
|
64
|
-
|
65
|
-
var optionalFoo = this.props.optionalProp.foo;
|
66
|
-
/** $FlowExpectedError: there is no prop `missingProp` **/
|
67
|
-
|
68
|
-
var missing = this.props.missingProp;
|
69
|
-
var defLen = this.props.defaultProp.length; // always a valid string, so no error
|
70
|
-
|
71
|
-
return require("react").createElement("div", null, reqLen && optionalProp && optionalFoo && missing && defLen);
|
72
|
-
};
|
73
|
-
|
74
|
-
return FooComponent;
|
75
|
-
}(require("react").Component); // Note that we must reassign to a new identifier to make sure flow doesn't propogate types without
|
76
|
-
// the relay type definition doing the work.
|
77
|
-
|
78
|
-
|
79
|
-
(0, _defineProperty2["default"])(FooComponent, "defaultProps", {
|
80
|
-
defaultProp: 'default'
|
81
|
-
});
|
82
|
-
|
83
|
-
var Foo = require("./ReactRelayPublic").createRefetchContainer(FooComponent, require("./ReactRelayPublic").graphql(_templateObject()), require("./ReactRelayPublic").graphql(_templateObject2()));
|
84
|
-
|
85
|
-
module.exports = {
|
86
|
-
checkMissingProp: function checkMissingProp() {
|
87
|
-
/** $ShouldBeFlowExpectedError: Foo missing `requiredProp` **/
|
88
|
-
return require("react").createElement(Foo, null);
|
89
|
-
},
|
90
|
-
checkMinimalProps: function checkMinimalProps() {
|
91
|
-
// All is well
|
92
|
-
return require("react").createElement(Foo, {
|
93
|
-
requiredProp: "foo"
|
94
|
-
});
|
95
|
-
},
|
96
|
-
checkWrongPropType: function checkWrongPropType() {
|
97
|
-
/** $ShouldBeFlowExpectedError: Foo1 wrong `requiredProp` type, should be string **/
|
98
|
-
return require("react").createElement(Foo, {
|
99
|
-
requiredProp: 17
|
100
|
-
});
|
101
|
-
},
|
102
|
-
checkWrongOptionalType: function checkWrongOptionalType() {
|
103
|
-
/** $ShouldBeFlowExpectedError: Foo wrong `optionalProp` type, should be `{foo: string}` **/
|
104
|
-
return require("react").createElement(Foo, {
|
105
|
-
optionalProp: "wrongType",
|
106
|
-
requiredProp: "foo"
|
107
|
-
});
|
108
|
-
},
|
109
|
-
checkNullOptionalType: function checkNullOptionalType() {
|
110
|
-
/** $ShouldBeFlowExpectedError: Foo `optionalProp` must be omitted or truthy, not null **/
|
111
|
-
return require("react").createElement(Foo, {
|
112
|
-
optionalProp: null,
|
113
|
-
requiredProp: "foo"
|
114
|
-
});
|
115
|
-
},
|
116
|
-
checkWrongDefaultPropType: function checkWrongDefaultPropType() {
|
117
|
-
/** $ShouldBeFlowExpectedError: Foo wrong `defaultProp` type, should be string **/
|
118
|
-
return require("react").createElement(Foo, {
|
119
|
-
defaultProp: false,
|
120
|
-
requiredProp: "foo"
|
121
|
-
});
|
122
|
-
},
|
123
|
-
checkAllPossibleProps: function checkAllPossibleProps() {
|
124
|
-
// All is well
|
125
|
-
return require("react").createElement(Foo, {
|
126
|
-
defaultProp: "bar",
|
127
|
-
optionalProp: {
|
128
|
-
foo: 42
|
129
|
-
},
|
130
|
-
requiredProp: "foo"
|
131
|
-
});
|
132
|
-
},
|
133
|
-
checkMinimalPropSpread: function checkMinimalPropSpread() {
|
134
|
-
// All is well
|
135
|
-
var props = {
|
136
|
-
requiredProp: 'foo'
|
137
|
-
};
|
138
|
-
return require("react").createElement(Foo, props);
|
139
|
-
},
|
140
|
-
checkMissingPropSpread: function checkMissingPropSpread() {
|
141
|
-
var props = {
|
142
|
-
defaultProp: 'foo'
|
143
|
-
};
|
144
|
-
/** $ShouldBeFlowExpectedError: Foo missing `requiredProp` with spread **/
|
145
|
-
|
146
|
-
return require("react").createElement(Foo, props);
|
147
|
-
},
|
148
|
-
checkStaticsAndMethodsProxying: function checkStaticsAndMethodsProxying() {
|
149
|
-
/* $FlowFixMe(>=0.53.0) This comment suppresses an
|
150
|
-
* error when upgrading Flow's support for React. Common errors found when
|
151
|
-
* upgrading Flow's React support are documented at
|
152
|
-
* https://fburl.com/eq7bs81w */
|
153
|
-
var ProxyChecker =
|
154
|
-
/*#__PURE__*/
|
155
|
-
function (_React$PureComponent) {
|
156
|
-
(0, _inheritsLoose2["default"])(ProxyChecker, _React$PureComponent);
|
157
|
-
|
158
|
-
function ProxyChecker() {
|
159
|
-
return _React$PureComponent.apply(this, arguments) || this;
|
160
|
-
}
|
161
|
-
|
162
|
-
var _proto2 = ProxyChecker.prototype;
|
163
|
-
|
164
|
-
_proto2.getString = function getString() {
|
165
|
-
var ok = this._fooRef ? this._fooRef.getNum() : 'default'; // legit
|
166
|
-
|
167
|
-
/** $FlowExpectedError: Foo does not have `missingMethod` **/
|
168
|
-
|
169
|
-
var bad = this._fooRef ? this._fooRef.missingMethod() : 'default';
|
170
|
-
/** $FlowExpectedError: Foo `getNum` gives number, but `getString` assumes string **/
|
171
|
-
|
172
|
-
return bad ? 'not good' : ok;
|
173
|
-
};
|
174
|
-
|
175
|
-
_proto2.render = function render() {
|
176
|
-
var _this = this;
|
177
|
-
|
178
|
-
return require("react").createElement(Foo, {
|
179
|
-
componentRef: function componentRef(ref) {
|
180
|
-
_this._fooRef = ref;
|
181
|
-
},
|
182
|
-
requiredProp: "bar"
|
183
|
-
});
|
184
|
-
};
|
185
|
-
|
186
|
-
return ProxyChecker;
|
187
|
-
}(require("react").PureComponent);
|
188
|
-
|
189
|
-
return require("react").createElement(ProxyChecker, null);
|
190
|
-
}
|
191
|
-
};
|
@@ -1,196 +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 _inheritsLoose2 = require("@babel/runtime/helpers/interopRequireDefault")(require("@babel/runtime/helpers/inheritsLoose"));
|
13
|
-
|
14
|
-
/**
|
15
|
-
* An asynchronous traversal that knows how to read roots and nodes from a
|
16
|
-
* `CacheManager`. Root reads yield the `dataID` of the root, if found.
|
17
|
-
* Node reads yield the `Record` associated with a supplied `dataID`, if found.
|
18
|
-
*
|
19
|
-
* Visitors: Ensure that only one read is ever in flight for a given root/node.
|
20
|
-
* Maintain a list of states to process after each read completes.
|
21
|
-
* Queuers: Perform the work of kicking off a root/node read.
|
22
|
-
* Handlers: Subclasses of `RelayCacheProcessor` can implement this method to
|
23
|
-
* actually perform work after a root/node read completes.
|
24
|
-
*/
|
25
|
-
var RelayCacheProcessor =
|
26
|
-
/*#__PURE__*/
|
27
|
-
function (_RelayQueryVisitor) {
|
28
|
-
(0, _inheritsLoose2["default"])(RelayCacheProcessor, _RelayQueryVisitor);
|
29
|
-
|
30
|
-
function RelayCacheProcessor(cacheManager, callbacks) {
|
31
|
-
var _this;
|
32
|
-
|
33
|
-
_this = _RelayQueryVisitor.call(this) || this;
|
34
|
-
_this._cacheManager = cacheManager;
|
35
|
-
_this._callbacks = callbacks;
|
36
|
-
_this._pendingNextStates = {};
|
37
|
-
_this._pendingRoots = {};
|
38
|
-
_this._state = 'PENDING';
|
39
|
-
return _this;
|
40
|
-
}
|
41
|
-
|
42
|
-
var _proto = RelayCacheProcessor.prototype;
|
43
|
-
|
44
|
-
_proto.abort = function abort() {
|
45
|
-
process.env.NODE_ENV !== "production" ? require("fbjs/lib/warning")(this._state === 'LOADING', 'RelayCacheProcessor: Can only abort an in-progress read operation.') : void 0;
|
46
|
-
this._state = 'COMPLETED';
|
47
|
-
};
|
48
|
-
|
49
|
-
_proto.handleFailure = function handleFailure(error) {
|
50
|
-
!(this._state !== 'COMPLETED') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayStoreReader: Query set already failed/completed.') : require("fbjs/lib/invariant")(false) : void 0;
|
51
|
-
this._state = 'COMPLETED';
|
52
|
-
this._callbacks.onFailure && this._callbacks.onFailure(error);
|
53
|
-
};
|
54
|
-
|
55
|
-
_proto.handleNodeVisited = function handleNodeVisited(node, dataID, record, nextState) {
|
56
|
-
return;
|
57
|
-
};
|
58
|
-
|
59
|
-
_proto.handleIdentifiedRootVisited = function handleIdentifiedRootVisited(query, dataID, identifyingArgKey, nextState) {
|
60
|
-
return;
|
61
|
-
};
|
62
|
-
|
63
|
-
_proto.process = function process(processorFn) {
|
64
|
-
!(this._state === 'PENDING') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayCacheProcessor: A `read` is in progress.') : require("fbjs/lib/invariant")(false) : void 0;
|
65
|
-
this._state = 'LOADING';
|
66
|
-
processorFn();
|
67
|
-
|
68
|
-
if (this._isDone()) {
|
69
|
-
this._handleSuccess();
|
70
|
-
}
|
71
|
-
};
|
72
|
-
|
73
|
-
_proto.queueIdentifiedRoot = function queueIdentifiedRoot(query, identifyingArgKey, nextState) {
|
74
|
-
var _this2 = this;
|
75
|
-
|
76
|
-
var storageKey = query.getStorageKey();
|
77
|
-
|
78
|
-
this._cacheManager.readRootCall(storageKey, identifyingArgKey || '', function (error, dataID) {
|
79
|
-
if (_this2._state === 'COMPLETED') {
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
|
83
|
-
if (error) {
|
84
|
-
_this2.handleFailure(error);
|
85
|
-
|
86
|
-
return;
|
87
|
-
}
|
88
|
-
|
89
|
-
_this2.handleIdentifiedRootVisited(query, dataID, identifyingArgKey, nextState);
|
90
|
-
|
91
|
-
var rootKey = _this2._getRootKey(storageKey, identifyingArgKey);
|
92
|
-
|
93
|
-
var pendingRoots = _this2._pendingRoots[rootKey];
|
94
|
-
delete _this2._pendingRoots[rootKey];
|
95
|
-
|
96
|
-
for (var ii = 0; ii < pendingRoots.length; ii++) {
|
97
|
-
if (_this2._state === 'COMPLETED') {
|
98
|
-
return;
|
99
|
-
}
|
100
|
-
|
101
|
-
_this2.traverse(pendingRoots[ii], nextState);
|
102
|
-
}
|
103
|
-
|
104
|
-
if (_this2._isDone()) {
|
105
|
-
_this2._handleSuccess();
|
106
|
-
}
|
107
|
-
});
|
108
|
-
};
|
109
|
-
|
110
|
-
_proto.queueNode = function queueNode(node, dataID, nextState) {
|
111
|
-
var _this3 = this;
|
112
|
-
|
113
|
-
this._cacheManager.readNode(dataID, function (error, record) {
|
114
|
-
if (_this3._state === 'COMPLETED') {
|
115
|
-
return;
|
116
|
-
}
|
117
|
-
|
118
|
-
if (error) {
|
119
|
-
_this3.handleFailure(error);
|
120
|
-
|
121
|
-
return;
|
122
|
-
}
|
123
|
-
|
124
|
-
_this3.handleNodeVisited(node, dataID, record, nextState);
|
125
|
-
|
126
|
-
var pendingNextStates = _this3._pendingNextStates[dataID];
|
127
|
-
delete _this3._pendingNextStates[dataID];
|
128
|
-
|
129
|
-
for (var ii = 0; ii < pendingNextStates.length; ii++) {
|
130
|
-
if (_this3._state === 'COMPLETED') {
|
131
|
-
return;
|
132
|
-
}
|
133
|
-
|
134
|
-
_this3.traverse(node, pendingNextStates[ii]);
|
135
|
-
}
|
136
|
-
|
137
|
-
if (_this3._isDone()) {
|
138
|
-
_this3._handleSuccess();
|
139
|
-
}
|
140
|
-
});
|
141
|
-
};
|
142
|
-
|
143
|
-
_proto.visitIdentifiedRoot = function visitIdentifiedRoot(query, identifyingArgKey, nextState) {
|
144
|
-
var storageKey = query.getStorageKey();
|
145
|
-
|
146
|
-
var rootKey = this._getRootKey(storageKey, identifyingArgKey);
|
147
|
-
|
148
|
-
if (this._pendingRoots.hasOwnProperty(rootKey)) {
|
149
|
-
this._pendingRoots[rootKey].push(query);
|
150
|
-
} else {
|
151
|
-
this._pendingRoots[rootKey] = [query];
|
152
|
-
this.queueIdentifiedRoot(query, identifyingArgKey, nextState);
|
153
|
-
}
|
154
|
-
};
|
155
|
-
|
156
|
-
_proto.visitNode = function visitNode(node, dataID, nextState) {
|
157
|
-
if (this._pendingNextStates.hasOwnProperty(dataID)) {
|
158
|
-
this._pendingNextStates[dataID].push(nextState);
|
159
|
-
} else {
|
160
|
-
this._pendingNextStates[dataID] = [nextState];
|
161
|
-
this.queueNode(node, dataID, nextState);
|
162
|
-
}
|
163
|
-
};
|
164
|
-
|
165
|
-
_proto.visitRoot = function visitRoot(query, nextState) {
|
166
|
-
var _this4 = this;
|
167
|
-
|
168
|
-
require("./forEachRootCallArg")(query, function (_ref) {
|
169
|
-
var identifyingArgKey = _ref.identifyingArgKey;
|
170
|
-
|
171
|
-
if (_this4._state === 'COMPLETED') {
|
172
|
-
return;
|
173
|
-
}
|
174
|
-
|
175
|
-
_this4.visitIdentifiedRoot(query, identifyingArgKey, nextState);
|
176
|
-
});
|
177
|
-
};
|
178
|
-
|
179
|
-
_proto._getRootKey = function _getRootKey(storageKey, identifyingArgKey) {
|
180
|
-
return "".concat(storageKey, "*").concat(identifyingArgKey || '');
|
181
|
-
};
|
182
|
-
|
183
|
-
_proto._handleSuccess = function _handleSuccess() {
|
184
|
-
!(this._state !== 'COMPLETED') ? process.env.NODE_ENV !== "production" ? require("fbjs/lib/invariant")(false, 'RelayStoreReader: Query set already failed/completed.') : require("fbjs/lib/invariant")(false) : void 0;
|
185
|
-
this._state = 'COMPLETED';
|
186
|
-
this._callbacks.onSuccess && this._callbacks.onSuccess();
|
187
|
-
};
|
188
|
-
|
189
|
-
_proto._isDone = function _isDone() {
|
190
|
-
return require("fbjs/lib/isEmpty")(this._pendingRoots) && require("fbjs/lib/isEmpty")(this._pendingNextStates) && this._state === 'LOADING';
|
191
|
-
};
|
192
|
-
|
193
|
-
return RelayCacheProcessor;
|
194
|
-
}(require("./RelayQueryVisitor"));
|
195
|
-
|
196
|
-
module.exports = RelayCacheProcessor;
|