relay-runtime 0.0.0-main-c9cf5515 → 0.0.0-main-91fd7b05
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/experimental.js +1 -1
- package/index.js +1 -1
- package/lib/query/fetchQuery.js +15 -3
- package/package.json +1 -1
- package/query/fetchQuery.js.flow +18 -5
- package/store/RelayStoreTypes.js.flow +11 -1
package/experimental.js
CHANGED
package/index.js
CHANGED
package/lib/query/fetchQuery.js
CHANGED
|
@@ -31,10 +31,22 @@ function fetchQuery(environment, query, variables, options) {
|
|
|
31
31
|
}
|
|
32
32
|
case 'store-or-network':
|
|
33
33
|
{
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
var queryAvailability = environment.check(operation);
|
|
35
|
+
var shouldFetch = queryAvailability.status !== 'available';
|
|
36
|
+
var observable;
|
|
37
|
+
if (!shouldFetch) {
|
|
38
|
+
observable = RelayObservable.from(environment.lookup(operation.fragment)).map(readData);
|
|
39
|
+
} else {
|
|
40
|
+
observable = getNetworkObservable(environment, operation).map(readData);
|
|
36
41
|
}
|
|
37
|
-
|
|
42
|
+
environment.__log({
|
|
43
|
+
name: 'fetchquery.fetch',
|
|
44
|
+
operation: operation,
|
|
45
|
+
fetchPolicy: fetchPolicy,
|
|
46
|
+
queryAvailability: queryAvailability,
|
|
47
|
+
shouldFetch: shouldFetch
|
|
48
|
+
});
|
|
49
|
+
return observable;
|
|
38
50
|
}
|
|
39
51
|
default:
|
|
40
52
|
fetchPolicy;
|
package/package.json
CHANGED
package/query/fetchQuery.js.flow
CHANGED
|
@@ -151,14 +151,27 @@ function fetchQuery<TVariables: Variables, TData, TRawResponse>(
|
|
|
151
151
|
);
|
|
152
152
|
}
|
|
153
153
|
case 'store-or-network': {
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
const queryAvailability = environment.check(operation);
|
|
155
|
+
const shouldFetch = queryAvailability.status !== 'available';
|
|
156
|
+
let observable;
|
|
157
|
+
if (!shouldFetch) {
|
|
158
|
+
observable = RelayObservable.from<Snapshot>(
|
|
156
159
|
environment.lookup(operation.fragment),
|
|
157
160
|
).map(readData);
|
|
161
|
+
} else {
|
|
162
|
+
observable = getNetworkObservable<$FlowFixMe>(
|
|
163
|
+
environment,
|
|
164
|
+
operation,
|
|
165
|
+
).map(readData);
|
|
158
166
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
167
|
+
environment.__log({
|
|
168
|
+
name: 'fetchquery.fetch',
|
|
169
|
+
operation,
|
|
170
|
+
fetchPolicy,
|
|
171
|
+
queryAvailability,
|
|
172
|
+
shouldFetch,
|
|
173
|
+
});
|
|
174
|
+
return observable;
|
|
162
175
|
}
|
|
163
176
|
default:
|
|
164
177
|
fetchPolicy as empty;
|
|
@@ -806,6 +806,15 @@ export type IdCollisionTypenameLogEvent = {
|
|
|
806
806
|
+new_typename: string,
|
|
807
807
|
};
|
|
808
808
|
|
|
809
|
+
export type FetchQueryFetchLogEvent = {
|
|
810
|
+
+name: 'fetchquery.fetch',
|
|
811
|
+
+operation: OperationDescriptor,
|
|
812
|
+
// FetchPolicy from Relay Hooks
|
|
813
|
+
+fetchPolicy: string,
|
|
814
|
+
+queryAvailability: OperationAvailability,
|
|
815
|
+
+shouldFetch: boolean,
|
|
816
|
+
};
|
|
817
|
+
|
|
809
818
|
export type LogEvent =
|
|
810
819
|
| SuspenseFragmentLogEvent
|
|
811
820
|
| SuspenseQueryLogEvent
|
|
@@ -845,7 +854,8 @@ export type LogEvent =
|
|
|
845
854
|
| EntrypointRootConsumeLogEvent
|
|
846
855
|
| LiveResolverBatchStartLogEvent
|
|
847
856
|
| LiveResolverBatchEndLogEvent
|
|
848
|
-
| UseFragmentSubscriptionMissedUpdates
|
|
857
|
+
| UseFragmentSubscriptionMissedUpdates
|
|
858
|
+
| FetchQueryFetchLogEvent;
|
|
849
859
|
|
|
850
860
|
export type LogFunction = LogEvent => void;
|
|
851
861
|
export type LogRequestInfoFunction = mixed => void;
|