react-relay 11.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 (149) hide show
  1. package/ReactRelayContext.js +1 -1
  2. package/ReactRelayContext.js.flow +2 -3
  3. package/ReactRelayFragmentContainer.js.flow +24 -24
  4. package/ReactRelayFragmentMockRenderer.js.flow +1 -1
  5. package/ReactRelayLocalQueryRenderer.js.flow +7 -8
  6. package/ReactRelayPaginationContainer.js.flow +111 -54
  7. package/ReactRelayQueryFetcher.js.flow +9 -10
  8. package/ReactRelayQueryRenderer.js.flow +115 -81
  9. package/ReactRelayRefetchContainer.js.flow +40 -35
  10. package/ReactRelayTestMocker.js.flow +16 -12
  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 +12 -7
  15. package/__flowtests__/ReactRelayRefetchContainer-flowtest.js.flow +10 -6
  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 +72 -0
  22. package/__flowtests__/__generated__/ReactRelayFragmentContainerFlowtest_viewer2.graphql.js.flow +72 -0
  23. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtestQuery.graphql.js.flow +227 -0
  24. package/__flowtests__/__generated__/ReactRelayPaginationContainerFlowtest_viewer.graphql.js.flow +164 -0
  25. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtestQuery.graphql.js.flow +227 -0
  26. package/__flowtests__/__generated__/ReactRelayRefetchContainerFlowtest_viewer.graphql.js.flow +164 -0
  27. package/__flowtests__/__generated__/RelayModernFlowtest_badref.graphql.js.flow +66 -0
  28. package/__flowtests__/__generated__/RelayModernFlowtest_notref.graphql.js.flow +66 -0
  29. package/__flowtests__/__generated__/RelayModernFlowtest_user.graphql.js.flow +59 -0
  30. package/__flowtests__/__generated__/RelayModernFlowtest_users.graphql.js.flow +61 -0
  31. package/assertFragmentMap.js.flow +2 -2
  32. package/buildReactRelayContainer.js.flow +15 -12
  33. package/getRootVariablesForFragments.js.flow +2 -3
  34. package/hooks.js +1 -1
  35. package/hooks.js.flow +5 -6
  36. package/index.js +1 -1
  37. package/index.js.flow +6 -7
  38. package/jest-react/enqueueTask.js.flow +56 -0
  39. package/jest-react/index.js.flow +12 -0
  40. package/jest-react/internalAct.js.flow +139 -0
  41. package/legacy.js +1 -1
  42. package/lib/ReactRelayFragmentContainer.js +21 -15
  43. package/lib/ReactRelayFragmentMockRenderer.js +2 -2
  44. package/lib/ReactRelayLocalQueryRenderer.js +7 -8
  45. package/lib/ReactRelayPaginationContainer.js +92 -30
  46. package/lib/ReactRelayQueryFetcher.js +3 -3
  47. package/lib/ReactRelayQueryRenderer.js +86 -53
  48. package/lib/ReactRelayRefetchContainer.js +36 -21
  49. package/lib/ReactRelayTestMocker.js +7 -6
  50. package/lib/RelayContext.js +3 -2
  51. package/lib/assertFragmentMap.js +3 -2
  52. package/lib/buildReactRelayContainer.js +14 -11
  53. package/lib/hooks.js +5 -5
  54. package/lib/index.js +7 -7
  55. package/lib/jest-react/enqueueTask.js +53 -0
  56. package/lib/jest-react/index.js +13 -0
  57. package/lib/jest-react/internalAct.js +116 -0
  58. package/lib/multi-actor/ActorChange.js +30 -0
  59. package/lib/multi-actor/index.js +11 -0
  60. package/lib/multi-actor/useRelayActorEnvironment.js +29 -0
  61. package/lib/relay-hooks/EntryPointContainer.react.js +3 -3
  62. package/lib/relay-hooks/FragmentResource.js +351 -94
  63. package/lib/relay-hooks/LRUCache.js +1 -1
  64. package/lib/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js +4 -4
  65. package/lib/relay-hooks/MatchContainer.js +1 -1
  66. package/lib/relay-hooks/QueryResource.js +172 -29
  67. package/lib/relay-hooks/RelayEnvironmentProvider.js +5 -3
  68. package/lib/relay-hooks/SuspenseResource.js +130 -0
  69. package/lib/relay-hooks/loadQuery.js +42 -20
  70. package/lib/relay-hooks/preloadQuery_DEPRECATED.js +24 -15
  71. package/lib/relay-hooks/useBlockingPaginationFragment.js +4 -5
  72. package/lib/relay-hooks/useEntryPointLoader.js +2 -2
  73. package/lib/relay-hooks/useFetchTrackingRef.js +2 -1
  74. package/lib/relay-hooks/useFragment.js +8 -7
  75. package/lib/relay-hooks/useFragmentNode.js +4 -4
  76. package/lib/relay-hooks/useIsOperationNodeActive.js +3 -3
  77. package/lib/relay-hooks/useLazyLoadQuery.js +3 -3
  78. package/lib/relay-hooks/useLazyLoadQueryNode.js +10 -4
  79. package/lib/relay-hooks/useLoadMoreFunction.js +6 -8
  80. package/lib/relay-hooks/useMemoOperationDescriptor.js +2 -2
  81. package/lib/relay-hooks/useMemoVariables.js +2 -2
  82. package/lib/relay-hooks/useMutation.js +17 -6
  83. package/lib/relay-hooks/usePaginationFragment.js +2 -3
  84. package/lib/relay-hooks/usePreloadedQuery.js +8 -7
  85. package/lib/relay-hooks/useQueryLoader.js +30 -10
  86. package/lib/relay-hooks/useRefetchableFragmentNode.js +12 -14
  87. package/lib/relay-hooks/useRelayEnvironment.js +3 -3
  88. package/lib/relay-hooks/useStaticFragmentNodeWarning.js +2 -2
  89. package/lib/relay-hooks/useSubscribeToInvalidationState.js +2 -1
  90. package/lib/relay-hooks/useSubscription.js +10 -7
  91. package/multi-actor/ActorChange.js.flow +58 -0
  92. package/multi-actor/index.js.flow +14 -0
  93. package/multi-actor/useRelayActorEnvironment.js.flow +49 -0
  94. package/package.json +3 -2
  95. package/react-relay-hooks.js +2 -2
  96. package/react-relay-hooks.min.js +2 -2
  97. package/react-relay-legacy.js +2 -2
  98. package/react-relay-legacy.min.js +2 -2
  99. package/react-relay.js +2 -2
  100. package/react-relay.min.js +2 -2
  101. package/relay-hooks/EntryPointContainer.react.js.flow +8 -15
  102. package/relay-hooks/EntryPointTypes.flow.js.flow +24 -25
  103. package/relay-hooks/FragmentResource.js.flow +376 -95
  104. package/relay-hooks/LazyLoadEntryPointContainer_DEPRECATED.react.js.flow +32 -46
  105. package/relay-hooks/MatchContainer.js.flow +3 -2
  106. package/relay-hooks/QueryResource.js.flow +216 -25
  107. package/relay-hooks/RelayEnvironmentProvider.js.flow +14 -4
  108. package/relay-hooks/SuspenseResource.js.flow +115 -0
  109. package/relay-hooks/__flowtests__/EntryPointTypes/EntryPointElementConfig-flowtest.js.flow +4 -3
  110. package/relay-hooks/__flowtests__/EntryPointTypes/NestedEntrypoints-flowtest.js.flow +1 -1
  111. package/relay-hooks/__flowtests__/useBlockingPaginationFragment-flowtest.js.flow +10 -9
  112. package/relay-hooks/__flowtests__/useFragment-flowtest.js.flow +8 -7
  113. package/relay-hooks/__flowtests__/usePaginationFragment-flowtest.js.flow +10 -9
  114. package/relay-hooks/__flowtests__/useRefetchableFragment-flowtest.js.flow +10 -9
  115. package/relay-hooks/__flowtests__/utils.js.flow +8 -12
  116. package/relay-hooks/loadEntryPoint.js.flow +6 -12
  117. package/relay-hooks/loadQuery.js.flow +49 -31
  118. package/relay-hooks/preloadQuery_DEPRECATED.js.flow +30 -21
  119. package/relay-hooks/prepareEntryPoint_DEPRECATED.js.flow +6 -12
  120. package/relay-hooks/useBlockingPaginationFragment.js.flow +13 -11
  121. package/relay-hooks/useEntryPointLoader.js.flow +7 -10
  122. package/relay-hooks/useFetchTrackingRef.js.flow +2 -2
  123. package/relay-hooks/useFragment.js.flow +26 -46
  124. package/relay-hooks/useFragmentNode.js.flow +5 -7
  125. package/relay-hooks/useIsOperationNodeActive.js.flow +3 -5
  126. package/relay-hooks/useIsParentQueryActive.js.flow +3 -4
  127. package/relay-hooks/useLazyLoadQuery.js.flow +9 -10
  128. package/relay-hooks/useLazyLoadQueryNode.js.flow +19 -13
  129. package/relay-hooks/useLoadMoreFunction.js.flow +20 -27
  130. package/relay-hooks/useMemoOperationDescriptor.js.flow +5 -7
  131. package/relay-hooks/useMemoVariables.js.flow +6 -6
  132. package/relay-hooks/useMutation.js.flow +26 -26
  133. package/relay-hooks/usePaginationFragment.js.flow +38 -44
  134. package/relay-hooks/usePreloadedQuery.js.flow +18 -14
  135. package/relay-hooks/useQueryLoader.js.flow +41 -22
  136. package/relay-hooks/useRefetchableFragment.js.flow +7 -8
  137. package/relay-hooks/useRefetchableFragmentNode.js.flow +24 -30
  138. package/relay-hooks/useRelayEnvironment.js.flow +2 -4
  139. package/relay-hooks/useStaticFragmentNodeWarning.js.flow +2 -3
  140. package/relay-hooks/useSubscribeToInvalidationState.js.flow +3 -6
  141. package/relay-hooks/useSubscription.js.flow +20 -10
  142. package/lib/relay-hooks/getPaginationMetadata.js +0 -41
  143. package/lib/relay-hooks/getPaginationVariables.js +0 -66
  144. package/lib/relay-hooks/getRefetchMetadata.js +0 -36
  145. package/lib/relay-hooks/getValueAtPath.js +0 -51
  146. package/relay-hooks/getPaginationMetadata.js.flow +0 -74
  147. package/relay-hooks/getPaginationVariables.js.flow +0 -108
  148. package/relay-hooks/getRefetchMetadata.js.flow +0 -80
  149. package/relay-hooks/getValueAtPath.js.flow +0 -46
@@ -15,18 +15,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
- var invariant = require("fbjs/lib/invariant");
19
-
20
18
  var _require = require('relay-runtime'),
21
- createOperationDescriptor = _require.createOperationDescriptor,
22
- Environment = _require.Environment,
23
- getRequest = _require.getRequest,
24
- getRequestIdentifier = _require.getRequestIdentifier,
25
19
  Observable = _require.Observable,
26
20
  PreloadableQueryRegistry = _require.PreloadableQueryRegistry,
27
- ReplaySubject = _require.ReplaySubject;
21
+ RelayFeatureFlags = _require.RelayFeatureFlags,
22
+ ReplaySubject = _require.ReplaySubject,
23
+ createOperationDescriptor = _require.createOperationDescriptor,
24
+ getRequest = _require.getRequest,
25
+ getRequestIdentifier = _require.getRequestIdentifier; // Expire results by this delay after they resolve.
26
+
28
27
 
29
- // Expire results by this delay after they resolve.
30
28
  var DEFAULT_PREFETCH_TIMEOUT = 30 * 1000; // 30 seconds
31
29
 
32
30
  var WEAKMAP_SUPPORTED = typeof WeakMap === 'function';
@@ -34,8 +32,6 @@ var STORE_OR_NETWORK_DEFAULT = 'store-or-network';
34
32
  var pendingQueriesByEnvironment = WEAKMAP_SUPPORTED ? new WeakMap() : new Map();
35
33
 
36
34
  function preloadQuery(environment, preloadableRequest, variables, options, environmentProviderOptions) {
37
- !(environment instanceof Environment) ? process.env.NODE_ENV !== "production" ? invariant(false, 'preloadQuery(): Expected a RelayModernEnvironment') : invariant(false) : void 0;
38
-
39
35
  var _pendingQueries = pendingQueriesByEnvironment.get(environment);
40
36
 
41
37
  if (_pendingQueries == null) {
@@ -63,7 +59,22 @@ function preloadQuery(environment, preloadableRequest, variables, options, envir
63
59
  var _subscription;
64
60
 
65
61
  (_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.unsubscribe();
66
- cleanup(pendingQueries, queryEntry);
62
+
63
+ if (environment.isServer()) {
64
+ return;
65
+ }
66
+
67
+ if (RelayFeatureFlags.DELAY_CLEANUP_OF_PENDING_PRELOAD_QUERIES === true) {
68
+ setTimeout(function () {
69
+ // Clear the cache entry after the default timeout
70
+ // null-check for Flow
71
+ if (queryEntry != null) {
72
+ cleanup(pendingQueries, queryEntry);
73
+ }
74
+ }, DEFAULT_PREFETCH_TIMEOUT);
75
+ } else {
76
+ cleanup(pendingQueries, queryEntry);
77
+ }
67
78
  };
68
79
  }) : null;
69
80
  return {
@@ -178,11 +189,9 @@ function preloadQueryDeduped(environment, pendingQueries, preloadableRequest, va
178
189
  };
179
190
  } else {
180
191
  nextQueryEntry = prevQueryEntry;
181
- } // $FlowFixMe[incompatible-call]
182
-
183
-
184
- pendingQueries.set(cacheKey, nextQueryEntry); // $FlowFixMe[incompatible-return]
192
+ }
185
193
 
194
+ pendingQueries.set(cacheKey, nextQueryEntry);
186
195
  return nextQueryEntry;
187
196
  }
188
197
 
@@ -17,16 +17,14 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
17
17
 
18
18
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
19
19
 
20
- var getPaginationMetadata = require('./getPaginationMetadata');
21
-
22
- var invariant = require("fbjs/lib/invariant");
23
-
24
20
  var useLoadMoreFunction = require('./useLoadMoreFunction');
25
21
 
26
22
  var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
27
23
 
28
24
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
29
25
 
26
+ var invariant = require('invariant');
27
+
30
28
  var _require = require('react'),
31
29
  useCallback = _require.useCallback,
32
30
  useEffect = _require.useEffect,
@@ -35,7 +33,8 @@ var _require = require('react'),
35
33
 
36
34
  var _require2 = require('relay-runtime'),
37
35
  getFragment = _require2.getFragment,
38
- getFragmentIdentifier = _require2.getFragmentIdentifier;
36
+ getFragmentIdentifier = _require2.getFragmentIdentifier,
37
+ getPaginationMetadata = _require2.getPaginationMetadata;
39
38
 
40
39
  function useBlockingPaginationFragment(fragmentInput, parentFragmentRef) {
41
40
  var componentDisplayName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'useBlockingPaginationFragment()';
@@ -17,11 +17,11 @@ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime
17
17
 
18
18
  var loadEntryPoint = require('./loadEntryPoint');
19
19
 
20
- var useIsMountedRef = require('./useIsMountedRef');
21
-
22
20
  var _require = require('./loadQuery'),
23
21
  useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
24
22
 
23
+ var useIsMountedRef = require('./useIsMountedRef');
24
+
25
25
  var _require2 = require('react'),
26
26
  useCallback = _require2.useCallback,
27
27
  useEffect = _require2.useEffect,
@@ -15,7 +15,6 @@ var _require = require('react'),
15
15
  useCallback = _require.useCallback,
16
16
  useEffect = _require.useEffect,
17
17
  useRef = _require.useRef;
18
-
19
18
  /**
20
19
  * This hook returns a mutable React ref that holds the value of whether a
21
20
  * fetch request is in flight. The reason this is a mutable ref instead of
@@ -28,6 +27,8 @@ var _require = require('react'),
28
27
  * The additional functions returned by this Hook can be used to mutate
29
28
  * the ref.
30
29
  */
30
+
31
+
31
32
  function useFetchTrackingRef() {
32
33
  var subscriptionRef = useRef(null);
33
34
  var isFetchingRef = useRef(false);
@@ -11,27 +11,28 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
+ var _require = require('./loadQuery'),
15
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
16
+
14
17
  var useFragmentNode = require('./useFragmentNode');
15
18
 
16
19
  var useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
17
20
 
18
- var _require = require('./loadQuery'),
19
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
20
-
21
21
  var _require2 = require('react'),
22
22
  useDebugValue = _require2.useDebugValue;
23
23
 
24
24
  var _require3 = require('relay-runtime'),
25
- getFragment = _require3.getFragment;
25
+ getFragment = _require3.getFragment; // if the key is non-nullable, return non-nullable value
26
+
26
27
 
27
- function useFragment(fragmentInput, fragmentRef) {
28
+ function useFragment(fragment, key) {
28
29
  // We need to use this hook in order to be able to track if
29
30
  // loadQuery was called during render
30
31
  useTrackLoadQueryInRender();
31
- var fragmentNode = getFragment(fragmentInput);
32
+ var fragmentNode = getFragment(fragment);
32
33
  useStaticFragmentNodeWarning(fragmentNode, 'first argument of useFragment()');
33
34
 
34
- var _useFragmentNode = useFragmentNode(fragmentNode, fragmentRef, 'useFragment()'),
35
+ var _useFragmentNode = useFragmentNode(fragmentNode, key, 'useFragment()'),
35
36
  data = _useFragmentNode.data;
36
37
 
37
38
  if (process.env.NODE_ENV !== "production") {
@@ -11,13 +11,11 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var useRelayEnvironment = require('./useRelayEnvironment');
15
-
16
- var warning = require("fbjs/lib/warning");
17
-
18
14
  var _require = require('./FragmentResource'),
19
15
  getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
20
16
 
17
+ var useRelayEnvironment = require('./useRelayEnvironment');
18
+
21
19
  var _require2 = require('react'),
22
20
  useEffect = _require2.useEffect,
23
21
  useRef = _require2.useRef,
@@ -26,6 +24,8 @@ var _require2 = require('react'),
26
24
  var _require3 = require('relay-runtime'),
27
25
  getFragmentIdentifier = _require3.getFragmentIdentifier;
28
26
 
27
+ var warning = require("fbjs/lib/warning");
28
+
29
29
  function useFragmentNode(fragmentNode, fragmentRef, componentDisplayName) {
30
30
  var environment = useRelayEnvironment();
31
31
  var FragmentResource = getFragmentResourceForEnvironment(environment);
@@ -10,11 +10,11 @@
10
10
  */
11
11
  'use strict';
12
12
 
13
- var React = require('react');
13
+ var useRelayEnvironment = require('./useRelayEnvironment');
14
14
 
15
- var invariant = require("fbjs/lib/invariant");
15
+ var invariant = require('invariant');
16
16
 
17
- var useRelayEnvironment = require('./useRelayEnvironment');
17
+ var React = require('react');
18
18
 
19
19
  var _require = require('relay-runtime'),
20
20
  getObservableForActiveRequest = _require.__internal.getObservableForActiveRequest,
@@ -11,15 +11,15 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
+ var _require = require('./loadQuery'),
15
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
16
+
14
17
  var useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
15
18
 
16
19
  var useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
17
20
 
18
21
  var useRelayEnvironment = require('./useRelayEnvironment');
19
22
 
20
- var _require = require('./loadQuery'),
21
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
22
-
23
23
  var _require2 = require('relay-runtime'),
24
24
  fetchQuery = _require2.__internal.fetchQuery;
25
25
 
@@ -13,7 +13,9 @@
13
13
 
14
14
  var ProfilerContext = require('./ProfilerContext');
15
15
 
16
- var React = require('react');
16
+ var _require = require('./QueryResource'),
17
+ getQueryCacheIdentifier = _require.getQueryCacheIdentifier,
18
+ getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment;
17
19
 
18
20
  var useFetchTrackingRef = require('./useFetchTrackingRef');
19
21
 
@@ -21,9 +23,7 @@ var useFragmentNode = require('./useFragmentNode');
21
23
 
22
24
  var useRelayEnvironment = require('./useRelayEnvironment');
23
25
 
24
- var _require = require('./QueryResource'),
25
- getQueryResourceForEnvironment = _require.getQueryResourceForEnvironment,
26
- getQueryCacheIdentifier = _require.getQueryCacheIdentifier;
26
+ var React = require('react');
27
27
 
28
28
  var useContext = React.useContext,
29
29
  useEffect = React.useEffect,
@@ -96,6 +96,12 @@ function useLazyLoadQueryNode(_ref) {
96
96
  // the effect should be re-executed and the query re-retained.
97
97
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
98
  }, [environment, cacheIdentifier]);
99
+ useEffect(function () {
100
+ // Release any temporary retain that's not released. At this point, if the
101
+ // cacheIdentifier doesn't change, the query is still permanently retained,
102
+ // and the temporary retain is redundant.
103
+ QueryResource.releaseTemporaryRetain(preparedQueryResult); // This effect is intended to run on every commit, thus no dependency
104
+ });
99
105
  var fragmentNode = preparedQueryResult.fragmentNode,
100
106
  fragmentRef = preparedQueryResult.fragmentRef;
101
107
 
@@ -15,12 +15,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
- var getPaginationVariables = require('./getPaginationVariables');
19
-
20
- var getValueAtPath = require('./getValueAtPath');
21
-
22
- var invariant = require("fbjs/lib/invariant");
23
-
24
18
  var useFetchTrackingRef = require('./useFetchTrackingRef');
25
19
 
26
20
  var useIsMountedRef = require('./useIsMountedRef');
@@ -29,7 +23,7 @@ var useIsOperationNodeActive = require('./useIsOperationNodeActive');
29
23
 
30
24
  var useRelayEnvironment = require('./useRelayEnvironment');
31
25
 
32
- var warning = require("fbjs/lib/warning");
26
+ var invariant = require('invariant');
33
27
 
34
28
  var _require = require('react'),
35
29
  useCallback = _require.useCallback,
@@ -40,7 +34,11 @@ var _require2 = require('relay-runtime'),
40
34
  ConnectionInterface = _require2.ConnectionInterface,
41
35
  fetchQuery = _require2.__internal.fetchQuery,
42
36
  createOperationDescriptor = _require2.createOperationDescriptor,
43
- getSelector = _require2.getSelector;
37
+ getPaginationVariables = _require2.getPaginationVariables,
38
+ getSelector = _require2.getSelector,
39
+ getValueAtPath = _require2.getValueAtPath;
40
+
41
+ var warning = require("fbjs/lib/warning");
44
42
 
45
43
  function useLoadMoreFunction(args) {
46
44
  var direction = args.direction,
@@ -11,10 +11,10 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var React = require('react');
15
-
16
14
  var useMemoVariables = require('./useMemoVariables');
17
15
 
16
+ var React = require('react');
17
+
18
18
  var _require = require('relay-runtime'),
19
19
  createOperationDescriptor = _require.createOperationDescriptor,
20
20
  getRequest = _require.getRequest;
@@ -11,10 +11,10 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var React = require('react');
15
-
16
14
  var areEqual = require("fbjs/lib/areEqual");
17
15
 
16
+ var React = require('react');
17
+
18
18
  var useMemo = React.useMemo,
19
19
  useRef = React.useRef,
20
20
  useState = React.useState;
@@ -15,10 +15,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
- var React = require('react');
18
+ var useIsMountedRef = require('./useIsMountedRef');
19
19
 
20
20
  var useRelayEnvironment = require('./useRelayEnvironment');
21
21
 
22
+ var React = require('react');
23
+
22
24
  var _require = require('relay-runtime'),
23
25
  defaultCommitMutation = _require.commitMutation;
24
26
 
@@ -27,8 +29,6 @@ var useState = React.useState,
27
29
  useRef = React.useRef,
28
30
  useCallback = React.useCallback;
29
31
 
30
- var useIsMountedRef = require('./useIsMountedRef');
31
-
32
32
  function useMutation(mutation) {
33
33
  var commitMutationFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCommitMutation;
34
34
  var environment = useRelayEnvironment();
@@ -66,16 +66,27 @@ function useMutation(mutation) {
66
66
  var disposable = commitMutationFn(environment, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, config), {}, {
67
67
  mutation: mutation,
68
68
  onCompleted: function onCompleted(response, errors) {
69
+ var _config$onCompleted;
70
+
69
71
  cleanup(disposable);
70
- config.onCompleted && config.onCompleted(response, errors);
72
+ (_config$onCompleted = config.onCompleted) === null || _config$onCompleted === void 0 ? void 0 : _config$onCompleted.call(config, response, errors);
71
73
  },
72
74
  onError: function onError(error) {
75
+ var _config$onError;
76
+
73
77
  cleanup(disposable);
74
- config.onError && config.onError(error);
78
+ (_config$onError = config.onError) === null || _config$onError === void 0 ? void 0 : _config$onError.call(config, error);
75
79
  },
76
80
  onUnsubscribe: function onUnsubscribe() {
81
+ var _config$onUnsubscribe;
82
+
77
83
  cleanup(disposable);
78
- config.onUnsubscribe && config.onUnsubscribe();
84
+ (_config$onUnsubscribe = config.onUnsubscribe) === null || _config$onUnsubscribe === void 0 ? void 0 : _config$onUnsubscribe.call(config);
85
+ },
86
+ onNext: function onNext() {
87
+ var _config$onNext;
88
+
89
+ (_config$onNext = config.onNext) === null || _config$onNext === void 0 ? void 0 : _config$onNext.call(config);
79
90
  }
80
91
  }));
81
92
  inFlightMutationsRef.current.add(disposable);
@@ -15,8 +15,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
- var getPaginationMetadata = require('./getPaginationMetadata');
19
-
20
18
  var useLoadMoreFunction = require('./useLoadMoreFunction');
21
19
 
22
20
  var useRefetchableFragmentNode = require('./useRefetchableFragmentNode');
@@ -30,7 +28,8 @@ var _require = require('react'),
30
28
 
31
29
  var _require2 = require('relay-runtime'),
32
30
  getFragment = _require2.getFragment,
33
- getFragmentIdentifier = _require2.getFragmentIdentifier;
31
+ getFragmentIdentifier = _require2.getFragmentIdentifier,
32
+ getPaginationMetadata = _require2.getPaginationMetadata;
34
33
 
35
34
  function usePaginationFragment(fragmentInput, parentFragmentRef) {
36
35
  var fragmentNode = getFragment(fragmentInput);
@@ -11,7 +11,8 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var invariant = require("fbjs/lib/invariant");
14
+ var _require = require('./loadQuery'),
15
+ useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
15
16
 
16
17
  var useLazyLoadQueryNode = require('./useLazyLoadQueryNode');
17
18
 
@@ -19,10 +20,7 @@ var useMemoOperationDescriptor = require('./useMemoOperationDescriptor');
19
20
 
20
21
  var useRelayEnvironment = require('./useRelayEnvironment');
21
22
 
22
- var warning = require("fbjs/lib/warning");
23
-
24
- var _require = require('./loadQuery'),
25
- useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
23
+ var invariant = require('invariant');
26
24
 
27
25
  var _require2 = require('react'),
28
26
  useDebugValue = _require2.useDebugValue;
@@ -32,6 +30,8 @@ var _require3 = require('relay-runtime'),
32
30
  fetchQueryDeduped = _require3$__internal.fetchQueryDeduped,
33
31
  fetchQuery = _require3$__internal.fetchQuery;
34
32
 
33
+ var warning = require("fbjs/lib/warning");
34
+
35
35
  function usePreloadedQuery(gqlQuery, preloadedQuery, options) {
36
36
  // We need to use this hook in order to be able to track if
37
37
  // loadQuery was called during render
@@ -40,8 +40,9 @@ function usePreloadedQuery(gqlQuery, preloadedQuery, options) {
40
40
  var fetchKey = preloadedQuery.fetchKey,
41
41
  fetchPolicy = preloadedQuery.fetchPolicy,
42
42
  source = preloadedQuery.source,
43
- variables = preloadedQuery.variables;
44
- var operation = useMemoOperationDescriptor(gqlQuery, variables);
43
+ variables = preloadedQuery.variables,
44
+ networkCacheConfig = preloadedQuery.networkCacheConfig;
45
+ var operation = useMemoOperationDescriptor(gqlQuery, variables, networkCacheConfig);
45
46
  var useLazyLoadQueryNodeParams;
46
47
 
47
48
  if (preloadedQuery.kind === 'PreloadedQuery_DEPRECATED') {
@@ -15,24 +15,36 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
17
17
 
18
- var useIsMountedRef = require('./useIsMountedRef');
19
-
20
- var useRelayEnvironment = require('./useRelayEnvironment');
21
-
22
18
  var _require = require('./loadQuery'),
23
19
  loadQuery = _require.loadQuery,
24
20
  useTrackLoadQueryInRender = _require.useTrackLoadQueryInRender;
25
21
 
22
+ var useIsMountedRef = require('./useIsMountedRef');
23
+
24
+ var useRelayEnvironment = require('./useRelayEnvironment');
25
+
26
26
  var _require2 = require('react'),
27
27
  useCallback = _require2.useCallback,
28
28
  useEffect = _require2.useEffect,
29
29
  useRef = _require2.useRef,
30
30
  useState = _require2.useState;
31
31
 
32
+ var _require3 = require('relay-runtime'),
33
+ getRequest = _require3.getRequest;
34
+
32
35
  var initialNullQueryReferenceState = {
33
36
  kind: 'NullQueryReference'
34
37
  };
35
38
 
39
+ function requestIsLiveQuery(preloadableRequest) {
40
+ if (preloadableRequest.kind === 'PreloadableConcreteRequest') {
41
+ return preloadableRequest.params.metadata.live !== undefined;
42
+ }
43
+
44
+ var request = getRequest(preloadableRequest);
45
+ return request.params.metadata.live !== undefined;
46
+ }
47
+
36
48
  function useQueryLoader(preloadableRequest, initialQueryReference) {
37
49
  /**
38
50
  * We want to always call `queryReference.dispose()` for every call to
@@ -175,7 +187,11 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
175
187
  undisposedQueryReferences["delete"](undisposedQueryReference);
176
188
 
177
189
  if (undisposedQueryReference.kind !== 'NullQueryReference') {
178
- undisposedQueryReference.dispose && undisposedQueryReference.dispose();
190
+ if (requestIsLiveQuery(preloadableRequest)) {
191
+ undisposedQueryReference.dispose && undisposedQueryReference.dispose();
192
+ } else {
193
+ undisposedQueryReference.releaseQuery && undisposedQueryReference.releaseQuery();
194
+ }
179
195
  }
180
196
  }
181
197
  } catch (err) {
@@ -184,7 +200,7 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
184
200
  _iterator.f();
185
201
  }
186
202
  }
187
- }, [queryReference, isMountedRef, queryLoaderCallback]);
203
+ }, [queryReference, isMountedRef, queryLoaderCallback, preloadableRequest]);
188
204
  useEffect(function () {
189
205
  return function disposeAllRemainingQueryReferences() {
190
206
  // undisposedQueryReferences.current is never reassigned
@@ -194,10 +210,14 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
194
210
 
195
211
  try {
196
212
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
197
- var unhandledStateChange = _step2.value;
213
+ var undisposedQueryReference = _step2.value;
198
214
 
199
- if (unhandledStateChange.kind !== 'NullQueryReference') {
200
- unhandledStateChange.dispose && unhandledStateChange.dispose();
215
+ if (undisposedQueryReference.kind !== 'NullQueryReference') {
216
+ if (requestIsLiveQuery(preloadableRequest)) {
217
+ undisposedQueryReference.dispose && undisposedQueryReference.dispose();
218
+ } else {
219
+ undisposedQueryReference.releaseQuery && undisposedQueryReference.releaseQuery();
220
+ }
201
221
  }
202
222
  }
203
223
  } catch (err) {
@@ -206,7 +226,7 @@ function useQueryLoader(preloadableRequest, initialQueryReference) {
206
226
  _iterator2.f();
207
227
  }
208
228
  };
209
- }, []);
229
+ }, [preloadableRequest]);
210
230
  return [queryReference.kind === 'NullQueryReference' ? null : queryReference, queryLoaderCallback, disposeQuery];
211
231
  }
212
232
 
@@ -15,13 +15,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
15
15
 
16
16
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
17
 
18
- var ProfilerContext = require('./ProfilerContext');
19
-
20
- var getRefetchMetadata = require('./getRefetchMetadata');
18
+ var _require = require('./FragmentResource'),
19
+ getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
21
20
 
22
- var getValueAtPath = require('./getValueAtPath');
21
+ var ProfilerContext = require('./ProfilerContext');
23
22
 
24
- var invariant = require("fbjs/lib/invariant");
23
+ var _require2 = require('./QueryResource'),
24
+ getQueryResourceForEnvironment = _require2.getQueryResourceForEnvironment;
25
25
 
26
26
  var useFragmentNode = require('./useFragmentNode');
27
27
 
@@ -31,13 +31,7 @@ var useQueryLoader = require('./useQueryLoader');
31
31
 
32
32
  var useRelayEnvironment = require('./useRelayEnvironment');
33
33
 
34
- var warning = require("fbjs/lib/warning");
35
-
36
- var _require = require('./FragmentResource'),
37
- getFragmentResourceForEnvironment = _require.getFragmentResourceForEnvironment;
38
-
39
- var _require2 = require('./QueryResource'),
40
- getQueryResourceForEnvironment = _require2.getQueryResourceForEnvironment;
34
+ var invariant = require('invariant');
41
35
 
42
36
  var _require3 = require('react'),
43
37
  useCallback = _require3.useCallback,
@@ -48,7 +42,11 @@ var _require4 = require('relay-runtime'),
48
42
  fetchQuery = _require4.__internal.fetchQuery,
49
43
  createOperationDescriptor = _require4.createOperationDescriptor,
50
44
  getFragmentIdentifier = _require4.getFragmentIdentifier,
51
- getSelector = _require4.getSelector;
45
+ getRefetchMetadata = _require4.getRefetchMetadata,
46
+ getSelector = _require4.getSelector,
47
+ getValueAtPath = _require4.getValueAtPath;
48
+
49
+ var warning = require("fbjs/lib/warning");
52
50
 
53
51
  function reducer(state, action) {
54
52
  switch (action.type) {
@@ -311,7 +309,7 @@ function useRefetchFunction(componentDisplayName, dispatch, disposeQuery, fragme
311
309
  // - fragmentNode and parentFragmentRef are also captured by including
312
310
  // fragmentIdentifier
313
311
  // eslint-disable-next-line react-hooks/exhaustive-deps
314
- [fragmentIdentifier, dispatch, disposeQuery, identifierValue]);
312
+ [fragmentIdentifier, dispatch, disposeQuery, identifierValue, loadQuery]);
315
313
  }
316
314
 
317
315
  var debugFunctions;
@@ -11,13 +11,13 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var ReactRelayContext = require('react-relay/ReactRelayContext');
15
-
16
- var invariant = require("fbjs/lib/invariant");
14
+ var invariant = require('invariant');
17
15
 
18
16
  var _require = require('react'),
19
17
  useContext = _require.useContext;
20
18
 
19
+ var ReactRelayContext = require('react-relay/ReactRelayContext');
20
+
21
21
  function useRelayEnvironment() {
22
22
  var context = useContext(ReactRelayContext);
23
23
  !(context != null) ? process.env.NODE_ENV !== "production" ? invariant(false, 'useRelayEnvironment: Expected to have found a Relay environment provided by ' + 'a `RelayEnvironmentProvider` component. ' + 'This usually means that useRelayEnvironment was used in a ' + 'component that is not a descendant of a `RelayEnvironmentProvider`. ' + 'Please make sure a `RelayEnvironmentProvider` has been rendered somewhere ' + 'as a parent or ancestor of your component.') : invariant(false) : void 0;
@@ -11,11 +11,11 @@
11
11
  // flowlint ambiguous-object-type:error
12
12
  'use strict';
13
13
 
14
- var warning = require("fbjs/lib/warning");
15
-
16
14
  var _require = require('react'),
17
15
  useRef = _require.useRef;
18
16
 
17
+ var warning = require("fbjs/lib/warning");
18
+
19
19
  function useStaticFragmentNodeWarning(fragmentNode, warningContext) {
20
20
  if (process.env.NODE_ENV !== "production") {
21
21
  // This is calling `useRef` conditionally, but based on the environment
@@ -16,7 +16,6 @@ var useRelayEnvironment = require('./useRelayEnvironment');
16
16
  var _require = require('react'),
17
17
  useEffect = _require.useEffect,
18
18
  useRef = _require.useRef;
19
-
20
19
  /**
21
20
  * This hook subscribes a callback to the invalidation state of the given data
22
21
  * ids.
@@ -26,6 +25,8 @@ var _require = require('react'),
26
25
  * re-established and the previous one will be disposed.
27
26
  * The subscription will automatically be disposed on unmount
28
27
  */
28
+
29
+
29
30
  function useSubscribeToInvalidationState(dataIDs, callback) {
30
31
  var environment = useRelayEnvironment();
31
32
  var disposableRef = useRef(null);