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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-c9cf5515
2
+ * Relay v0.0.0-main-91fd7b05
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Relay v0.0.0-main-c9cf5515
2
+ * Relay v0.0.0-main-91fd7b05
3
3
  *
4
4
  * Copyright (c) Meta Platforms, Inc. and affiliates.
5
5
  *
@@ -31,10 +31,22 @@ function fetchQuery(environment, query, variables, options) {
31
31
  }
32
32
  case 'store-or-network':
33
33
  {
34
- if (environment.check(operation).status === 'available') {
35
- return RelayObservable.from(environment.lookup(operation.fragment)).map(readData);
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
- return getNetworkObservable(environment, operation).map(readData);
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "relay-runtime",
3
3
  "description": "A core runtime for building GraphQL-driven applications.",
4
- "version": "0.0.0-main-c9cf5515",
4
+ "version": "0.0.0-main-91fd7b05",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "relay"
@@ -151,14 +151,27 @@ function fetchQuery<TVariables: Variables, TData, TRawResponse>(
151
151
  );
152
152
  }
153
153
  case 'store-or-network': {
154
- if (environment.check(operation).status === 'available') {
155
- return RelayObservable.from<Snapshot>(
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
- return getNetworkObservable<$FlowFixMe>(environment, operation).map(
160
- readData,
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;