react-relay 12.0.0 → 13.0.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. package/ReactRelayContext.js +1 -1
  2. package/ReactRelayContext.js.flow +2 -3
  3. package/ReactRelayFragmentContainer.js.flow +10 -16
  4. package/ReactRelayFragmentMockRenderer.js.flow +1 -1
  5. package/ReactRelayLocalQueryRenderer.js.flow +6 -7
  6. package/ReactRelayPaginationContainer.js.flow +29 -39
  7. package/ReactRelayQueryFetcher.js.flow +9 -10
  8. package/ReactRelayQueryRenderer.js.flow +15 -15
  9. package/ReactRelayRefetchContainer.js.flow +24 -32
  10. package/ReactRelayTestMocker.js.flow +16 -14
  11. package/ReactRelayTypes.js.flow +10 -10
  12. package/RelayContext.js.flow +3 -3
  13. package/__flowtests__/ReactRelayFragmentContainer-flowtest.js.flow +1 -2
  14. package/__flowtests__/ReactRelayPaginationContainer-flowtest.js.flow +1 -2
  15. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +1 -2
  16. package/__flowtests__/RelayModern-flowtest.js.flow +78 -46
  17. package/__flowtests__/RelayModernFlowtest_badref.graphql.js.flow +5 -4
  18. package/__flowtests__/RelayModernFlowtest_notref.graphql.js.flow +5 -4
  19. package/__flowtests__/RelayModernFlowtest_user.graphql.js.flow +4 -3
  20. package/__flowtests__/RelayModernFlowtest_users.graphql.js.flow +4 -3
  21. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer.graphql.js.flow +13 -10
  22. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +13 -10
  23. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +13 -8
  24. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +13 -10
  25. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +13 -8
  26. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +13 -10
  27. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +15 -12
  28. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +15 -12
  29. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +13 -10
  30. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +13 -10
  31. package/assertFragmentMap.js.flow +2 -2
  32. package/buildReactRelayContainer.js.flow +11 -10
  33. package/getRootVariablesForFragments.js.flow +2 -4
  34. package/hooks.js +1 -1
  35. package/hooks.js.flow +3 -5
  36. package/index.js +1 -1
  37. package/index.js.flow +4 -6
  38. package/jest-react/enqueueTask.js.flow +1 -1
  39. package/jest-react/internalAct.js.flow +1 -2
  40. package/legacy.js +1 -1
  41. package/lib/ReactRelayFragmentContainer.js +4 -4
  42. package/lib/ReactRelayFragmentMockRenderer.js +2 -2
  43. package/lib/ReactRelayLocalQueryRenderer.js +7 -8
  44. package/lib/ReactRelayPaginationContainer.js +18 -22
  45. package/lib/ReactRelayQueryFetcher.js +2 -2
  46. package/lib/ReactRelayQueryRenderer.js +4 -4
  47. package/lib/ReactRelayRefetchContainer.js +12 -14
  48. package/lib/ReactRelayTestMocker.js +7 -8
  49. package/lib/RelayContext.js +3 -2
  50. package/lib/assertFragmentMap.js +2 -1
  51. package/lib/buildReactRelayContainer.js +7 -7
  52. package/lib/getRootVariablesForFragments.js +1 -2
  53. package/lib/hooks.js +5 -5
  54. package/lib/index.js +7 -7
  55. package/lib/jest-react/internalAct.js +2 -2
  56. package/lib/multi-actor/ActorChange.js +2 -2
  57. package/lib/multi-actor/useRelayActorEnvironment.js +2 -2
  58. package/lib/relay-hooks/EntryPointContainer.react.js +3 -3
  59. package/lib/relay-hooks/FragmentResource.js +241 -45
  60. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +4 -4
  61. package/lib/relay-hooks/MatchContainer.js +1 -1
  62. package/lib/relay-hooks/QueryResource.js +83 -4
  63. package/lib/relay-hooks/SuspenseResource.js +130 -0
  64. package/lib/relay-hooks/loadQuery.js +8 -9
  65. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +24 -10
  66. package/lib/relay-hooks/useBlockingPaginationFragment.js +2 -2
  67. package/lib/relay-hooks/useEntryPointLoader.js +2 -2
  68. package/lib/relay-hooks/useFetchTrackingRef.js +2 -1
  69. package/lib/relay-hooks/useFragment.js +8 -7
  70. package/lib/relay-hooks/useFragmentNode.js +4 -4
  71. package/lib/relay-hooks/useIsOperationNodeActive.js +2 -2
  72. package/lib/relay-hooks/useLazyLoadQuery.js +3 -3
  73. package/lib/relay-hooks/useLazyLoadQueryNode.js +4 -4
  74. package/lib/relay-hooks/useLoadMoreFunction.js +7 -9
  75. package/lib/relay-hooks/useMemoOperationDescriptor.js +2 -2
  76. package/lib/relay-hooks/useMemoVariables.js +2 -2
  77. package/lib/relay-hooks/useMutation.js +17 -6
  78. package/lib/relay-hooks/usePreloadedQuery.js +5 -5
  79. package/lib/relay-hooks/useQueryLoader.js +4 -4
  80. package/lib/relay-hooks/useRefetchableFragmentNode.js +10 -12
  81. package/lib/relay-hooks/useRelayEnvironment.js +2 -2
  82. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -2
  83. package/lib/relay-hooks/useSubscribeToInvalidationState.js +2 -1
  84. package/multi-actor/ActorChange.js.flow +3 -4
  85. package/multi-actor/useRelayActorEnvironment.js.flow +5 -7
  86. package/package.json +2 -2
  87. package/react-relay-hooks.js +2 -2
  88. package/react-relay-hooks.min.js +2 -2
  89. package/react-relay-legacy.js +2 -2
  90. package/react-relay-legacy.min.js +2 -2
  91. package/react-relay.js +2 -2
  92. package/react-relay.min.js +2 -2
  93. package/relay-hooks/EntryPointContainer.react.js.flow +8 -15
  94. package/relay-hooks/EntryPointTypes.flow.js.flow +18 -24
  95. package/relay-hooks/FragmentResource.js.flow +220 -34
  96. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +32 -46
  97. package/relay-hooks/MatchContainer.js.flow +3 -2
  98. package/relay-hooks/QueryResource.js.flow +119 -17
  99. package/relay-hooks/RelayEnvironmentProvider.js.flow +9 -9
  100. package/relay-hooks/SuspenseResource.js.flow +115 -0
  101. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +4 -3
  102. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +1 -1
  103. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +10 -9
  104. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +8 -7
  105. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +10 -9
  106. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +10 -9
  107. package/relay-hooks/__flowtests__/utils.js.flow +8 -12
  108. package/relay-hooks/loadEntryPoint.js.flow +6 -12
  109. package/relay-hooks/loadQuery.js.flow +22 -23
  110. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +29 -13
  111. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +6 -12
  112. package/relay-hooks/useBlockingPaginationFragment.js.flow +12 -13
  113. package/relay-hooks/useEntryPointLoader.js.flow +7 -10
  114. package/relay-hooks/useFetchTrackingRef.js.flow +2 -2
  115. package/relay-hooks/useFragment.js.flow +26 -46
  116. package/relay-hooks/useFragmentNode.js.flow +5 -7
  117. package/relay-hooks/useIsOperationNodeActive.js.flow +3 -5
  118. package/relay-hooks/useIsParentQueryActive.js.flow +3 -4
  119. package/relay-hooks/useLazyLoadQuery.js.flow +9 -10
  120. package/relay-hooks/useLazyLoadQueryNode.js.flow +11 -13
  121. package/relay-hooks/useLoadMoreFunction.js.flow +19 -27
  122. package/relay-hooks/useMemoOperationDescriptor.js.flow +5 -7
  123. package/relay-hooks/useMemoVariables.js.flow +6 -6
  124. package/relay-hooks/useMutation.js.flow +26 -26
  125. package/relay-hooks/usePaginationFragment.js.flow +37 -46
  126. package/relay-hooks/usePreloadedQuery.js.flow +13 -19
  127. package/relay-hooks/useQueryLoader.js.flow +13 -16
  128. package/relay-hooks/useRefetchableFragment.js.flow +7 -8
  129. package/relay-hooks/useRefetchableFragmentNode.js.flow +22 -30
  130. package/relay-hooks/useRelayEnvironment.js.flow +2 -4
  131. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +2 -3
  132. package/relay-hooks/useSubscribeToInvalidationState.js.flow +3 -6
  133. package/relay-hooks/useSubscription.js.flow +6 -7
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v12.0.0
2
+ * Relay v13.0.0-rc.0
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
5
5
  *
@@ -11,14 +11,13 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
 
13
13
  'use strict';
14
- const React = require('react');
14
+ import type {RelayContext} from 'relay-runtime/store/RelayStoreTypes';
15
15
 
16
+ const React = require('react');
16
17
  const {
17
18
  __internal: {createRelayContext},
18
19
  } = require('relay-runtime');
19
20
 
20
- import type {RelayContext} from 'relay-runtime/store/RelayStoreTypes';
21
-
22
21
  module.exports = (createRelayContext(
23
22
  React,
24
23
  ): React$Context<RelayContext | null>);
@@ -12,26 +12,24 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
15
+ import type {GeneratedNodeMap, RelayProp, $RelayProps} from './ReactRelayTypes';
16
+ import type {
17
+ FragmentMap,
18
+ FragmentSpecResolver,
19
+ RelayContext,
20
+ } from 'relay-runtime';
16
21
 
17
- const areEqual = require('areEqual');
18
22
  const buildReactRelayContainer = require('./buildReactRelayContainer');
19
-
20
23
  const {getContainerName} = require('./ReactRelayContainerUtils');
21
24
  const {assertRelayContext} = require('./RelayContext');
25
+ const areEqual = require('areEqual');
26
+ const React = require('react');
22
27
  const {
23
28
  createFragmentSpecResolver,
24
29
  getDataIDsFromObject,
25
30
  isScalarAndEqual,
26
31
  } = require('relay-runtime');
27
32
 
28
- import type {$RelayProps, GeneratedNodeMap, RelayProp} from './ReactRelayTypes';
29
- import type {
30
- FragmentMap,
31
- FragmentSpecResolver,
32
- RelayContext,
33
- } from 'relay-runtime';
34
-
35
33
  type ContainerProps = $FlowFixMeProps;
36
34
  type ContainerState = {
37
35
  data: {[key: string]: mixed, ...},
@@ -237,12 +235,8 @@ function createContainerWithFragments<
237
235
  }
238
236
 
239
237
  render() {
240
- const {
241
- componentRef,
242
- __relayContext,
243
- __rootIsQueryRenderer,
244
- ...props
245
- } = this.props;
238
+ const {componentRef, __relayContext, __rootIsQueryRenderer, ...props} =
239
+ this.props;
246
240
  return React.createElement(Component, {
247
241
  ...props,
248
242
  ...this.state.data,
@@ -12,8 +12,8 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
15
  const ReactRelayContext = require('./ReactRelayContext');
16
+ const React = require('react');
17
17
 
18
18
  function ReactRelayFragmentMockRenderer(props: Object): React.Node {
19
19
  return (
@@ -12,21 +12,20 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
15
+ import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
16
+ import type {GraphQLTaggedNode, IEnvironment, Variables} from 'relay-runtime';
17
+
16
18
  const ReactRelayContext = require('./ReactRelayContext');
17
19
  const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
18
-
19
- const {useLayoutEffect, useState, useRef, useMemo} = React;
20
+ const areEqual = require('areEqual');
21
+ const React = require('react');
20
22
  const {
21
23
  createOperationDescriptor,
22
24
  deepFreeze,
23
25
  getRequest,
24
26
  } = require('relay-runtime');
25
27
 
26
- const areEqual = require('areEqual');
27
-
28
- import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
29
- import type {GraphQLTaggedNode, IEnvironment, Variables} from 'relay-runtime';
28
+ const {useLayoutEffect, useState, useRef, useMemo} = React;
30
29
 
31
30
  type Props = {
32
31
  environment: IEnvironment,
@@ -12,39 +12,12 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
- const ReactRelayContext = require('./ReactRelayContext');
17
- const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
18
-
19
- const areEqual = require('areEqual');
20
- const buildReactRelayContainer = require('./buildReactRelayContainer');
21
- const getRootVariablesForFragments = require('./getRootVariablesForFragments');
22
- const invariant = require('invariant');
23
- const warning = require('warning');
24
-
25
- const {
26
- getComponentName,
27
- getContainerName,
28
- } = require('./ReactRelayContainerUtils');
29
- const {assertRelayContext} = require('./RelayContext');
30
- const {
31
- ConnectionInterface,
32
- Observable,
33
- createFragmentSpecResolver,
34
- createOperationDescriptor,
35
- getDataIDsFromObject,
36
- getRequest,
37
- getVariablesFromObject,
38
- isScalarAndEqual,
39
- RelayFeatureFlags,
40
- } = require('relay-runtime');
41
-
42
15
  import type {
43
- $RelayProps,
44
- ObserverOrCallback,
45
16
  GeneratedNodeMap,
17
+ ObserverOrCallback,
46
18
  RefetchOptions,
47
19
  RelayPaginationProp,
20
+ $RelayProps,
48
21
  } from './ReactRelayTypes';
49
22
  import type {
50
23
  CacheConfig,
@@ -60,6 +33,31 @@ import type {
60
33
  Variables,
61
34
  } from 'relay-runtime';
62
35
 
36
+ const buildReactRelayContainer = require('./buildReactRelayContainer');
37
+ const getRootVariablesForFragments = require('./getRootVariablesForFragments');
38
+ const {
39
+ getComponentName,
40
+ getContainerName,
41
+ } = require('./ReactRelayContainerUtils');
42
+ const ReactRelayContext = require('./ReactRelayContext');
43
+ const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
44
+ const {assertRelayContext} = require('./RelayContext');
45
+ const areEqual = require('areEqual');
46
+ const invariant = require('invariant');
47
+ const React = require('react');
48
+ const {
49
+ ConnectionInterface,
50
+ Observable,
51
+ RelayFeatureFlags,
52
+ createFragmentSpecResolver,
53
+ createOperationDescriptor,
54
+ getDataIDsFromObject,
55
+ getRequest,
56
+ getVariablesFromObject,
57
+ isScalarAndEqual,
58
+ } = require('relay-runtime');
59
+ const warning = require('warning');
60
+
63
61
  type ContainerState = {
64
62
  data: {[key: string]: mixed, ...},
65
63
  relayProp: RelayPaginationProp,
@@ -258,7 +256,6 @@ function createGetFragmentVariables(
258
256
  'ReactRelayPaginationContainer: Unable to synthesize a ' +
259
257
  'getFragmentVariables function.',
260
258
  );
261
- // $FlowFixMe[cannot-spread-interface]
262
259
  return (prevVars: Variables, totalCount: number) => ({
263
260
  ...prevVars,
264
261
  [countVariable]: totalCount,
@@ -766,9 +763,7 @@ function createContainerWithFragments<
766
763
  };
767
764
  let fragmentVariables;
768
765
  const rootVariables = getRootVariablesForFragments(fragments, restProps);
769
- // $FlowFixMe[cannot-spread-interface]
770
766
  fragmentVariables = getVariablesFromObject(fragments, restProps);
771
- // $FlowFixMe[cannot-spread-interface]
772
767
  fragmentVariables = {
773
768
  ...rootVariables,
774
769
  ...fragmentVariables,
@@ -789,7 +784,6 @@ function createContainerWithFragments<
789
784
  fetchVariables,
790
785
  componentName,
791
786
  );
792
- // $FlowFixMe[cannot-spread-interface]
793
787
  fetchVariables = {
794
788
  ...fetchVariables,
795
789
  ...this._refetchVariables,
@@ -906,12 +900,8 @@ function createContainerWithFragments<
906
900
  }
907
901
 
908
902
  render() {
909
- const {
910
- componentRef,
911
- __relayContext,
912
- __rootIsQueryRenderer,
913
- ...props
914
- } = this.props;
903
+ const {componentRef, __relayContext, __rootIsQueryRenderer, ...props} =
904
+ this.props;
915
905
  return (
916
906
  <ReactRelayContext.Provider value={this.state.contextForChildren}>
917
907
  <Component
@@ -12,14 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const invariant = require('invariant');
16
-
17
- const {
18
- createOperationDescriptor,
19
- isRelayModernEnvironment,
20
- __internal: {fetchQuery},
21
- } = require('relay-runtime');
22
-
23
15
  import type {
24
16
  CacheConfig,
25
17
  Disposable,
@@ -29,6 +21,13 @@ import type {
29
21
  Snapshot,
30
22
  } from 'relay-runtime';
31
23
 
24
+ const invariant = require('invariant');
25
+ const {
26
+ __internal: {fetchQuery},
27
+ createOperationDescriptor,
28
+ isRelayModernEnvironment,
29
+ } = require('relay-runtime');
30
+
32
31
  type OnDataChange = ({
33
32
  error?: Error,
34
33
  snapshot?: Snapshot,
@@ -341,8 +340,8 @@ class ReactRelayQueryFetcher {
341
340
  this._rootSubscription = environment.subscribe(this._snapshot, snapshot => {
342
341
  // Read from this._fetchOptions in case onDataChange() was lazily added.
343
342
  if (this._fetchOptions != null) {
344
- const maybeNewOnDataChangeCallbacks = this._fetchOptions
345
- .onDataChangeCallbacks;
343
+ const maybeNewOnDataChangeCallbacks =
344
+ this._fetchOptions.onDataChangeCallbacks;
346
345
  if (Array.isArray(maybeNewOnDataChangeCallbacks)) {
347
346
  maybeNewOnDataChangeCallbacks.forEach(onDataChange =>
348
347
  onDataChange({snapshot}),
@@ -12,20 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
- const ReactRelayContext = require('./ReactRelayContext');
17
- const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
18
- const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
19
-
20
- const areEqual = require('areEqual');
21
-
22
- const {
23
- createOperationDescriptor,
24
- deepFreeze,
25
- getRequest,
26
- RelayFeatureFlags,
27
- } = require('relay-runtime');
28
-
29
15
  import type {ReactRelayQueryRendererContext as ReactRelayQueryRendererContextType} from './ReactRelayQueryRendererContext';
30
16
  import type {
31
17
  CacheConfig,
@@ -36,6 +22,19 @@ import type {
36
22
  Snapshot,
37
23
  Variables,
38
24
  } from 'relay-runtime';
25
+
26
+ const ReactRelayContext = require('./ReactRelayContext');
27
+ const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
28
+ const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext');
29
+ const areEqual = require('areEqual');
30
+ const React = require('react');
31
+ const {
32
+ RelayFeatureFlags,
33
+ createOperationDescriptor,
34
+ deepFreeze,
35
+ getRequest,
36
+ } = require('relay-runtime');
37
+
39
38
  type RetryCallbacks = {|
40
39
  handleDataChange:
41
40
  | null
@@ -340,7 +339,8 @@ function resetQueryStateForUpdate(
340
339
  ): $Shape<State> {
341
340
  const {query} = props;
342
341
 
343
- const prevSelectionReferences = prevState.queryFetcher.getSelectionReferences();
342
+ const prevSelectionReferences =
343
+ prevState.queryFetcher.getSelectionReferences();
344
344
  prevState.queryFetcher.disposeRequest();
345
345
 
346
346
  let queryFetcher;
@@ -12,33 +12,12 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
- const ReactRelayContext = require('./ReactRelayContext');
17
- const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
18
-
19
- const areEqual = require('areEqual');
20
- const buildReactRelayContainer = require('./buildReactRelayContainer');
21
- const getRootVariablesForFragments = require('./getRootVariablesForFragments');
22
- const warning = require('warning');
23
-
24
- const {getContainerName} = require('./ReactRelayContainerUtils');
25
- const {assertRelayContext} = require('./RelayContext');
26
- const {
27
- Observable,
28
- createFragmentSpecResolver,
29
- createOperationDescriptor,
30
- getDataIDsFromObject,
31
- getRequest,
32
- getVariablesFromObject,
33
- isScalarAndEqual,
34
- } = require('relay-runtime');
35
-
36
15
  import type {
37
- $RelayProps,
38
- ObserverOrCallback,
39
16
  GeneratedNodeMap,
17
+ ObserverOrCallback,
40
18
  RefetchOptions,
41
19
  RelayRefetchProp,
20
+ $RelayProps,
42
21
  } from './ReactRelayTypes';
43
22
  import type {
44
23
  CacheConfig,
@@ -51,6 +30,25 @@ import type {
51
30
  } from 'relay-runtime';
52
31
  import type {FragmentSpecResolver} from 'relay-runtime';
53
32
 
33
+ const buildReactRelayContainer = require('./buildReactRelayContainer');
34
+ const getRootVariablesForFragments = require('./getRootVariablesForFragments');
35
+ const {getContainerName} = require('./ReactRelayContainerUtils');
36
+ const ReactRelayContext = require('./ReactRelayContext');
37
+ const ReactRelayQueryFetcher = require('./ReactRelayQueryFetcher');
38
+ const {assertRelayContext} = require('./RelayContext');
39
+ const areEqual = require('areEqual');
40
+ const React = require('react');
41
+ const {
42
+ Observable,
43
+ createFragmentSpecResolver,
44
+ createOperationDescriptor,
45
+ getDataIDsFromObject,
46
+ getRequest,
47
+ getVariablesFromObject,
48
+ isScalarAndEqual,
49
+ } = require('relay-runtime');
50
+ const warning = require('warning');
51
+
54
52
  type ContainerProps = $FlowFixMeProps;
55
53
 
56
54
  type ContainerState = {
@@ -332,11 +330,9 @@ function createContainerWithFragments<
332
330
  typeof refetchVariables === 'function'
333
331
  ? refetchVariables(this._getFragmentVariables())
334
332
  : refetchVariables;
335
- // $FlowFixMe[cannot-spread-interface]
336
333
  fetchVariables = {...rootVariables, ...fetchVariables};
337
334
  const fragmentVariables = renderVariables
338
- ? // $FlowFixMe[cannot-spread-interface]
339
- {...fetchVariables, ...renderVariables}
335
+ ? {...fetchVariables, ...renderVariables}
340
336
  : fetchVariables;
341
337
 
342
338
  const cacheConfig: ?CacheConfig = options
@@ -452,12 +448,8 @@ function createContainerWithFragments<
452
448
  };
453
449
 
454
450
  render() {
455
- const {
456
- componentRef,
457
- __relayContext,
458
- __rootIsQueryRenderer,
459
- ...props
460
- } = this.props;
451
+ const {componentRef, __relayContext, __rootIsQueryRenderer, ...props} =
452
+ this.props;
461
453
  const {relayProp, contextForChildren} = this.state;
462
454
  return (
463
455
  <ReactRelayContext.Provider value={contextForChildren}>
@@ -12,16 +12,6 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const areEqual = require('areEqual');
16
- const invariant = require('invariant');
17
- const warning = require('warning');
18
-
19
- const {
20
- createOperationDescriptor,
21
- isRelayModernEnvironment,
22
- Network,
23
- } = require('relay-runtime');
24
-
25
15
  import type {
26
16
  CacheConfig,
27
17
  ConcreteRequest,
@@ -32,6 +22,15 @@ import type {
32
22
  Variables,
33
23
  } from 'relay-runtime';
34
24
 
25
+ const areEqual = require('areEqual');
26
+ const invariant = require('invariant');
27
+ const {
28
+ Network,
29
+ createOperationDescriptor,
30
+ isRelayModernEnvironment,
31
+ } = require('relay-runtime');
32
+ const warning = require('warning');
33
+
35
34
  export type DataWriteConfig = {
36
35
  query: ConcreteRequest,
37
36
  variables: Variables,
@@ -66,7 +65,7 @@ let nextId = 0;
66
65
 
67
66
  class ReactRelayTestMocker {
68
67
  _environment: IEnvironment;
69
- _defaults: {[string]: $PropertyType<NetworkWriteConfig, 'payload'>, ...} = {};
68
+ _defaults: {[string]: NetworkWriteConfig['payload'], ...} = {};
70
69
  _pendingFetches: Array<PendingFetch> = [];
71
70
 
72
71
  constructor(env: IEnvironment) {
@@ -118,7 +117,6 @@ class ReactRelayTestMocker {
118
117
  * annoying to test (e.g. client_mutation_id, actor_id)
119
118
  */
120
119
  static stripUnused(variables: Variables): Variables {
121
- // $FlowFixMe[prop-missing]
122
120
  if (variables.input) {
123
121
  const toRemove = [
124
122
  'client_mutation_id',
@@ -126,7 +124,6 @@ class ReactRelayTestMocker {
126
124
  'clientMutationId',
127
125
  'actorId',
128
126
  ];
129
- // $FlowFixMe[cannot-spread-interface]
130
127
  const strippedVariables = {...variables, input: {...variables.input}};
131
128
  toRemove.forEach(item => (strippedVariables.input[item] = undefined));
132
129
  return strippedVariables;
@@ -143,7 +140,11 @@ class ReactRelayTestMocker {
143
140
  * their components behave under error conditions.
144
141
  */
145
142
  _mockNetworkLayer(env: IEnvironment): IEnvironment {
146
- const fetch = (request, variables, cacheConfig) => {
143
+ const fetch = (
144
+ request: RequestParameters,
145
+ variables: Variables,
146
+ cacheConfig: CacheConfig,
147
+ ) => {
147
148
  let resolve;
148
149
  let reject;
149
150
  const promise = new Promise((res, rej) => {
@@ -314,6 +315,7 @@ class ReactRelayTestMocker {
314
315
  );
315
316
 
316
317
  const realPayload =
318
+ // $FlowFixMe[incompatible-call]
317
319
  typeof payload === 'function' ? payload(toResolve.variables) : payload;
318
320
 
319
321
  // if there are errors, reject the query
@@ -14,7 +14,7 @@
14
14
 
15
15
  import type {
16
16
  Disposable,
17
- FragmentReference,
17
+ FragmentType,
18
18
  GraphQLTaggedNode,
19
19
  IEnvironment,
20
20
  Observer,
@@ -94,7 +94,7 @@ export type RefetchOptions = {|
94
94
  *
95
95
  */
96
96
  export type $FragmentRef<T> = {
97
- +$fragmentRefs: $PropertyType<T, '$refType'>,
97
+ +$fragmentSpreads: T['$fragmentType'],
98
98
  ...
99
99
  };
100
100
 
@@ -105,14 +105,14 @@ export type $FragmentRef<T> = {
105
105
  // prettier-ignore
106
106
  export type $RelayProps<Props, RelayPropT = RelayProp> = $ObjMap<
107
107
  $Diff<Props, { relay: RelayPropT | void, ... }>,
108
- & (<T: { +$refType: empty, ... }>( T) => T)
109
- & (<T: { +$refType: empty, ... }>(?T) => ?T)
110
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>( T ) => $FragmentRef<T> )
111
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>(? T ) => ? $FragmentRef<T> )
112
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>( $ReadOnlyArray< T>) => $ReadOnlyArray< $FragmentRef<T>>)
113
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>(?$ReadOnlyArray< T>) => ?$ReadOnlyArray< $FragmentRef<T>>)
114
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>( $ReadOnlyArray<?T>) => $ReadOnlyArray<?$FragmentRef<T>>)
115
- & (<TRef: FragmentReference, T: { +$refType: TRef, ... }>(?$ReadOnlyArray<?T>) => ?$ReadOnlyArray<?$FragmentRef<T>>)
108
+ & (<T: { +$fragmentType: empty, ... }>( T) => T)
109
+ & (<T: { +$fragmentType: empty, ... }>(?T) => ?T)
110
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( T ) => $FragmentRef<T> )
111
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(? T ) => ? $FragmentRef<T> )
112
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( $ReadOnlyArray< T>) => $ReadOnlyArray< $FragmentRef<T>>)
113
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(?$ReadOnlyArray< T>) => ?$ReadOnlyArray< $FragmentRef<T>>)
114
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>( $ReadOnlyArray<?T>) => $ReadOnlyArray<?$FragmentRef<T>>)
115
+ & (<TFragmentType: FragmentType, T: { +$fragmentType: TFragmentType, ... }>(?$ReadOnlyArray<?T>) => ?$ReadOnlyArray<?$FragmentRef<T>>)
116
116
  & (<T>(T) => T),
117
117
  >;
118
118
 
@@ -12,11 +12,11 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const invariant = require('invariant');
16
- const isRelayEnvironment = require('./isRelayEnvironment');
17
-
18
15
  import type {RelayContext} from 'relay-runtime';
19
16
 
17
+ const isRelayEnvironment = require('./isRelayEnvironment');
18
+ const invariant = require('invariant');
19
+
20
20
  /**
21
21
  * Asserts that the input is a matches the `RelayContext` type defined in
22
22
  * `RelayEnvironmentTypes` and returns it as that type.
@@ -12,11 +12,10 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
-
17
15
  const {
18
16
  createContainer: createFragmentContainer,
19
17
  } = require('../ReactRelayFragmentContainer');
18
+ const React = require('react');
20
19
  const {graphql} = require('relay-runtime');
21
20
 
22
21
  /**
@@ -12,11 +12,10 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
-
17
15
  const {
18
16
  createContainer: createPaginationContainer,
19
17
  } = require('../ReactRelayPaginationContainer');
18
+ const React = require('react');
20
19
  const {graphql} = require('relay-runtime');
21
20
 
22
21
  /**
@@ -12,11 +12,10 @@
12
12
 
13
13
  'use strict';
14
14
 
15
- const React = require('react');
16
-
17
15
  const {
18
16
  createContainer: createRefetchContainer,
19
17
  } = require('../ReactRelayRefetchContainer');
18
+ const React = require('react');
20
19
  const {graphql} = require('relay-runtime');
21
20
 
22
21
  /**