houdini 1.2.36 → 1.2.38
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/build/cmd-cjs/index.js +2775 -3175
- package/build/cmd-esm/index.js +2775 -3175
- package/build/codegen/utils/stripLoc.d.ts +3 -0
- package/build/codegen-cjs/index.js +2761 -3162
- package/build/codegen-esm/index.js +2761 -3162
- package/build/lib-cjs/index.js +2198 -2607
- package/build/lib-esm/index.js +2198 -2607
- package/build/runtime/cache/cache.d.ts +3 -2
- package/build/runtime/client/documentStore.d.ts +2 -2
- package/build/runtime/lib/types.d.ts +2 -0
- package/build/runtime-cjs/cache/cache.d.ts +3 -2
- package/build/runtime-cjs/cache/cache.js +15 -16
- package/build/runtime-cjs/client/documentStore.d.ts +2 -2
- package/build/runtime-cjs/client/plugins/cache.js +3 -2
- package/build/runtime-cjs/lib/pagination.js +8 -2
- package/build/runtime-cjs/lib/types.d.ts +2 -0
- package/build/runtime-cjs/lib/types.js +2 -1
- package/build/runtime-esm/cache/cache.d.ts +3 -2
- package/build/runtime-esm/cache/cache.js +12 -14
- package/build/runtime-esm/client/documentStore.d.ts +2 -2
- package/build/runtime-esm/client/plugins/cache.js +3 -2
- package/build/runtime-esm/lib/pagination.js +8 -2
- package/build/runtime-esm/lib/types.d.ts +2 -0
- package/build/runtime-esm/lib/types.js +2 -1
- package/build/test-cjs/index.js +2765 -3165
- package/build/test-esm/index.js +2765 -3165
- package/build/vite-cjs/index.js +2779 -3180
- package/build/vite-esm/index.js +2779 -3180
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from '../lib/config';
|
|
2
|
-
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap } from '../lib/types';
|
|
2
|
+
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap, ValueNode } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
@@ -148,9 +148,10 @@ declare class CacheInternal {
|
|
|
148
148
|
};
|
|
149
149
|
collectGarbage(): void;
|
|
150
150
|
}
|
|
151
|
-
export declare function
|
|
151
|
+
export declare function evaluateVariables(variables: ValueMap, args: GraphQLObject): {
|
|
152
152
|
[k: string]: GraphQLValue;
|
|
153
153
|
};
|
|
154
|
+
export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
|
|
154
155
|
export declare const rootID = "_ROOT_";
|
|
155
156
|
export declare function fragmentReference({ component, prop, }: {
|
|
156
157
|
component: {
|
|
@@ -81,12 +81,12 @@ export type ClientPluginEnterHandlers = {
|
|
|
81
81
|
/** Returns the marshaled variables for the operation */
|
|
82
82
|
marshalVariables: typeof marshalVariables;
|
|
83
83
|
};
|
|
84
|
-
/** Exit handlers are the same as enter
|
|
84
|
+
/** Exit handlers are the same as enter handlers but don't need to resolve with a specific value */
|
|
85
85
|
export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'> & {
|
|
86
86
|
resolve: (ctx: ClientPluginContext, data?: QueryResult) => void;
|
|
87
87
|
value: QueryResult;
|
|
88
88
|
};
|
|
89
|
-
/** Exit handlers are the same as enter
|
|
89
|
+
/** Exit handlers are the same as enter handlers but don't need to resolve with a specific value */
|
|
90
90
|
export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
|
|
91
91
|
error: unknown;
|
|
92
92
|
};
|
|
@@ -4,6 +4,7 @@ export declare const CachePolicy: {
|
|
|
4
4
|
readonly CacheOnly: "CacheOnly";
|
|
5
5
|
readonly NetworkOnly: "NetworkOnly";
|
|
6
6
|
readonly CacheAndNetwork: "CacheAndNetwork";
|
|
7
|
+
readonly NoCache: "NoCache";
|
|
7
8
|
};
|
|
8
9
|
export type CachePolicies = ValuesOf<typeof CachePolicy>;
|
|
9
10
|
export declare const PaginateMode: {
|
|
@@ -70,6 +71,7 @@ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
|
|
|
70
71
|
export type InputObject = {
|
|
71
72
|
fields: Record<string, string>;
|
|
72
73
|
types: Record<string, Record<string, string>>;
|
|
74
|
+
defaults: Record<string, any>;
|
|
73
75
|
};
|
|
74
76
|
export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
|
|
75
77
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from '../lib/config';
|
|
2
|
-
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap } from '../lib/types';
|
|
2
|
+
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap, ValueNode } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
@@ -148,9 +148,10 @@ declare class CacheInternal {
|
|
|
148
148
|
};
|
|
149
149
|
collectGarbage(): void;
|
|
150
150
|
}
|
|
151
|
-
export declare function
|
|
151
|
+
export declare function evaluateVariables(variables: ValueMap, args: GraphQLObject): {
|
|
152
152
|
[k: string]: GraphQLValue;
|
|
153
153
|
};
|
|
154
|
+
export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
|
|
154
155
|
export declare const rootID = "_ROOT_";
|
|
155
156
|
export declare function fragmentReference({ component, prop, }: {
|
|
156
157
|
component: {
|
|
@@ -20,9 +20,10 @@ var cache_exports = {};
|
|
|
20
20
|
__export(cache_exports, {
|
|
21
21
|
Cache: () => Cache,
|
|
22
22
|
defaultComponentField: () => defaultComponentField,
|
|
23
|
-
|
|
23
|
+
evaluateVariables: () => evaluateVariables,
|
|
24
24
|
fragmentReference: () => fragmentReference,
|
|
25
|
-
rootID: () => rootID
|
|
25
|
+
rootID: () => rootID,
|
|
26
|
+
variableValue: () => variableValue
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(cache_exports);
|
|
28
29
|
var import_lib = require("../lib");
|
|
@@ -555,10 +556,7 @@ class CacheInternal {
|
|
|
555
556
|
key,
|
|
556
557
|
{
|
|
557
558
|
parent,
|
|
558
|
-
variables:
|
|
559
|
-
value.arguments,
|
|
560
|
-
variables ?? {}
|
|
561
|
-
)
|
|
559
|
+
variables: evaluateVariables(value.arguments, variables ?? {})
|
|
562
560
|
}
|
|
563
561
|
])
|
|
564
562
|
)
|
|
@@ -592,7 +590,7 @@ class CacheInternal {
|
|
|
592
590
|
return d.name === "include";
|
|
593
591
|
});
|
|
594
592
|
if (includeDirective) {
|
|
595
|
-
if (!
|
|
593
|
+
if (!evaluateVariables(includeDirective.arguments, variables ?? {})["if"]) {
|
|
596
594
|
continue;
|
|
597
595
|
}
|
|
598
596
|
}
|
|
@@ -600,7 +598,7 @@ class CacheInternal {
|
|
|
600
598
|
return d.name === "skip";
|
|
601
599
|
});
|
|
602
600
|
if (skipDirective) {
|
|
603
|
-
if (
|
|
601
|
+
if (evaluateVariables(skipDirective.arguments, variables ?? {})["if"]) {
|
|
604
602
|
continue;
|
|
605
603
|
}
|
|
606
604
|
}
|
|
@@ -899,9 +897,9 @@ class CacheInternal {
|
|
|
899
897
|
}
|
|
900
898
|
}
|
|
901
899
|
}
|
|
902
|
-
function
|
|
900
|
+
function evaluateVariables(variables, args) {
|
|
903
901
|
return Object.fromEntries(
|
|
904
|
-
Object.entries(variables).map(([key, value]) => [key,
|
|
902
|
+
Object.entries(variables).map(([key, value]) => [key, variableValue(value, args)])
|
|
905
903
|
);
|
|
906
904
|
}
|
|
907
905
|
function wrapInLists(target, count = 0) {
|
|
@@ -910,7 +908,7 @@ function wrapInLists(target, count = 0) {
|
|
|
910
908
|
}
|
|
911
909
|
return wrapInLists([target], count - 1);
|
|
912
910
|
}
|
|
913
|
-
function
|
|
911
|
+
function variableValue(value, args) {
|
|
914
912
|
if (value.kind === "StringValue") {
|
|
915
913
|
return value.value;
|
|
916
914
|
}
|
|
@@ -933,13 +931,13 @@ function fragmentVariableValue(value, args) {
|
|
|
933
931
|
return args[value.name.value];
|
|
934
932
|
}
|
|
935
933
|
if (value.kind === "ListValue") {
|
|
936
|
-
return value.values.map((value2) =>
|
|
934
|
+
return value.values.map((value2) => variableValue(value2, args));
|
|
937
935
|
}
|
|
938
936
|
if (value.kind === "ObjectValue") {
|
|
939
937
|
return value.fields.reduce(
|
|
940
938
|
(obj, field) => ({
|
|
941
939
|
...obj,
|
|
942
|
-
[field.name.value]:
|
|
940
|
+
[field.name.value]: variableValue(field.value, args)
|
|
943
941
|
}),
|
|
944
942
|
{}
|
|
945
943
|
);
|
|
@@ -961,7 +959,7 @@ function defaultComponentField({
|
|
|
961
959
|
}) {
|
|
962
960
|
return (props) => {
|
|
963
961
|
const componentFn = cache._internal_unstable.componentCache[component.key];
|
|
964
|
-
const args =
|
|
962
|
+
const args = evaluateVariables(component.variables ?? {}, variables ?? {});
|
|
965
963
|
return cache._internal_unstable.createComponent(componentFn, {
|
|
966
964
|
...props,
|
|
967
965
|
[component.prop]: {
|
|
@@ -982,7 +980,8 @@ function defaultComponentField({
|
|
|
982
980
|
0 && (module.exports = {
|
|
983
981
|
Cache,
|
|
984
982
|
defaultComponentField,
|
|
985
|
-
|
|
983
|
+
evaluateVariables,
|
|
986
984
|
fragmentReference,
|
|
987
|
-
rootID
|
|
985
|
+
rootID,
|
|
986
|
+
variableValue
|
|
988
987
|
});
|
|
@@ -81,12 +81,12 @@ export type ClientPluginEnterHandlers = {
|
|
|
81
81
|
/** Returns the marshaled variables for the operation */
|
|
82
82
|
marshalVariables: typeof marshalVariables;
|
|
83
83
|
};
|
|
84
|
-
/** Exit handlers are the same as enter
|
|
84
|
+
/** Exit handlers are the same as enter handlers but don't need to resolve with a specific value */
|
|
85
85
|
export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'> & {
|
|
86
86
|
resolve: (ctx: ClientPluginContext, data?: QueryResult) => void;
|
|
87
87
|
value: QueryResult;
|
|
88
88
|
};
|
|
89
|
-
/** Exit handlers are the same as enter
|
|
89
|
+
/** Exit handlers are the same as enter handlers but don't need to resolve with a specific value */
|
|
90
90
|
export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
|
|
91
91
|
error: unknown;
|
|
92
92
|
};
|
|
@@ -42,7 +42,8 @@ const cachePolicy = ({
|
|
|
42
42
|
const { policy, artifact } = ctx;
|
|
43
43
|
let useCache = false;
|
|
44
44
|
if (enabled && (artifact.kind === import_types.ArtifactKind.Query || artifact.kind === import_types.ArtifactKind.Fragment) && !ctx.cacheParams?.disableRead) {
|
|
45
|
-
|
|
45
|
+
const policyAllowsCache = policy !== import_types.CachePolicy.NetworkOnly && policy !== import_types.CachePolicy.NoCache;
|
|
46
|
+
if (policyAllowsCache) {
|
|
46
47
|
const value = localCache.read({
|
|
47
48
|
selection: artifact.selection,
|
|
48
49
|
variables: marshalVariables(ctx),
|
|
@@ -96,7 +97,7 @@ const cachePolicy = ({
|
|
|
96
97
|
return next(ctx);
|
|
97
98
|
},
|
|
98
99
|
afterNetwork(ctx, { resolve, value, marshalVariables }) {
|
|
99
|
-
if (value.source !== import_types.DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
|
|
100
|
+
if (ctx.policy !== import_types.CachePolicy.NoCache && value.source !== import_types.DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
|
|
100
101
|
if (ctx.cacheParams && "serverSideFallback" in ctx.cacheParams) {
|
|
101
102
|
serverSideFallback = ctx.cacheParams?.serverSideFallback ?? serverSideFallback;
|
|
102
103
|
}
|
|
@@ -164,7 +164,14 @@ function offsetHandlers({
|
|
|
164
164
|
fetchUpdate: parentFetchUpdate,
|
|
165
165
|
getSession
|
|
166
166
|
}) {
|
|
167
|
-
let
|
|
167
|
+
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
168
|
+
let getOffset = () => {
|
|
169
|
+
let offset = artifact.refetch?.start || (0, import_pageInfo.countPage)(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
|
|
170
|
+
if (isSinglePage) {
|
|
171
|
+
offset += getVariables()?.offset ?? 0;
|
|
172
|
+
}
|
|
173
|
+
return offset;
|
|
174
|
+
};
|
|
168
175
|
let currentOffset = getOffset() ?? 0;
|
|
169
176
|
return {
|
|
170
177
|
loadNextPage: async ({
|
|
@@ -183,7 +190,6 @@ function offsetHandlers({
|
|
|
183
190
|
if (!queryVariables.limit && !artifact.refetch.pageSize) {
|
|
184
191
|
throw (0, import_pageInfo.missingPageSizeError)("loadNextPage");
|
|
185
192
|
}
|
|
186
|
-
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
187
193
|
const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
|
|
188
194
|
await targetFetch({
|
|
189
195
|
variables: queryVariables,
|
|
@@ -4,6 +4,7 @@ export declare const CachePolicy: {
|
|
|
4
4
|
readonly CacheOnly: "CacheOnly";
|
|
5
5
|
readonly NetworkOnly: "NetworkOnly";
|
|
6
6
|
readonly CacheAndNetwork: "CacheAndNetwork";
|
|
7
|
+
readonly NoCache: "NoCache";
|
|
7
8
|
};
|
|
8
9
|
export type CachePolicies = ValuesOf<typeof CachePolicy>;
|
|
9
10
|
export declare const PaginateMode: {
|
|
@@ -70,6 +71,7 @@ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
|
|
|
70
71
|
export type InputObject = {
|
|
71
72
|
fields: Record<string, string>;
|
|
72
73
|
types: Record<string, Record<string, string>>;
|
|
74
|
+
defaults: Record<string, any>;
|
|
73
75
|
};
|
|
74
76
|
export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
|
|
75
77
|
name: string;
|
|
@@ -38,7 +38,8 @@ const CachePolicy = {
|
|
|
38
38
|
CacheOrNetwork: "CacheOrNetwork",
|
|
39
39
|
CacheOnly: "CacheOnly",
|
|
40
40
|
NetworkOnly: "NetworkOnly",
|
|
41
|
-
CacheAndNetwork: "CacheAndNetwork"
|
|
41
|
+
CacheAndNetwork: "CacheAndNetwork",
|
|
42
|
+
NoCache: "NoCache"
|
|
42
43
|
};
|
|
43
44
|
const PaginateMode = {
|
|
44
45
|
Infinite: "Infinite",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from '../lib/config';
|
|
2
|
-
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap } from '../lib/types';
|
|
2
|
+
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap, ValueNode } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
@@ -148,9 +148,10 @@ declare class CacheInternal {
|
|
|
148
148
|
};
|
|
149
149
|
collectGarbage(): void;
|
|
150
150
|
}
|
|
151
|
-
export declare function
|
|
151
|
+
export declare function evaluateVariables(variables: ValueMap, args: GraphQLObject): {
|
|
152
152
|
[k: string]: GraphQLValue;
|
|
153
153
|
};
|
|
154
|
+
export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
|
|
154
155
|
export declare const rootID = "_ROOT_";
|
|
155
156
|
export declare function fragmentReference({ component, prop, }: {
|
|
156
157
|
component: {
|
|
@@ -528,10 +528,7 @@ class CacheInternal {
|
|
|
528
528
|
key,
|
|
529
529
|
{
|
|
530
530
|
parent,
|
|
531
|
-
variables:
|
|
532
|
-
value.arguments,
|
|
533
|
-
variables ?? {}
|
|
534
|
-
)
|
|
531
|
+
variables: evaluateVariables(value.arguments, variables ?? {})
|
|
535
532
|
}
|
|
536
533
|
])
|
|
537
534
|
)
|
|
@@ -565,7 +562,7 @@ class CacheInternal {
|
|
|
565
562
|
return d.name === "include";
|
|
566
563
|
});
|
|
567
564
|
if (includeDirective) {
|
|
568
|
-
if (!
|
|
565
|
+
if (!evaluateVariables(includeDirective.arguments, variables ?? {})["if"]) {
|
|
569
566
|
continue;
|
|
570
567
|
}
|
|
571
568
|
}
|
|
@@ -573,7 +570,7 @@ class CacheInternal {
|
|
|
573
570
|
return d.name === "skip";
|
|
574
571
|
});
|
|
575
572
|
if (skipDirective) {
|
|
576
|
-
if (
|
|
573
|
+
if (evaluateVariables(skipDirective.arguments, variables ?? {})["if"]) {
|
|
577
574
|
continue;
|
|
578
575
|
}
|
|
579
576
|
}
|
|
@@ -872,9 +869,9 @@ class CacheInternal {
|
|
|
872
869
|
}
|
|
873
870
|
}
|
|
874
871
|
}
|
|
875
|
-
function
|
|
872
|
+
function evaluateVariables(variables, args) {
|
|
876
873
|
return Object.fromEntries(
|
|
877
|
-
Object.entries(variables).map(([key, value]) => [key,
|
|
874
|
+
Object.entries(variables).map(([key, value]) => [key, variableValue(value, args)])
|
|
878
875
|
);
|
|
879
876
|
}
|
|
880
877
|
function wrapInLists(target, count = 0) {
|
|
@@ -883,7 +880,7 @@ function wrapInLists(target, count = 0) {
|
|
|
883
880
|
}
|
|
884
881
|
return wrapInLists([target], count - 1);
|
|
885
882
|
}
|
|
886
|
-
function
|
|
883
|
+
function variableValue(value, args) {
|
|
887
884
|
if (value.kind === "StringValue") {
|
|
888
885
|
return value.value;
|
|
889
886
|
}
|
|
@@ -906,13 +903,13 @@ function fragmentVariableValue(value, args) {
|
|
|
906
903
|
return args[value.name.value];
|
|
907
904
|
}
|
|
908
905
|
if (value.kind === "ListValue") {
|
|
909
|
-
return value.values.map((value2) =>
|
|
906
|
+
return value.values.map((value2) => variableValue(value2, args));
|
|
910
907
|
}
|
|
911
908
|
if (value.kind === "ObjectValue") {
|
|
912
909
|
return value.fields.reduce(
|
|
913
910
|
(obj, field) => ({
|
|
914
911
|
...obj,
|
|
915
|
-
[field.name.value]:
|
|
912
|
+
[field.name.value]: variableValue(field.value, args)
|
|
916
913
|
}),
|
|
917
914
|
{}
|
|
918
915
|
);
|
|
@@ -934,7 +931,7 @@ function defaultComponentField({
|
|
|
934
931
|
}) {
|
|
935
932
|
return (props) => {
|
|
936
933
|
const componentFn = cache._internal_unstable.componentCache[component.key];
|
|
937
|
-
const args =
|
|
934
|
+
const args = evaluateVariables(component.variables ?? {}, variables ?? {});
|
|
938
935
|
return cache._internal_unstable.createComponent(componentFn, {
|
|
939
936
|
...props,
|
|
940
937
|
[component.prop]: {
|
|
@@ -954,7 +951,8 @@ function defaultComponentField({
|
|
|
954
951
|
export {
|
|
955
952
|
Cache,
|
|
956
953
|
defaultComponentField,
|
|
957
|
-
|
|
954
|
+
evaluateVariables,
|
|
958
955
|
fragmentReference,
|
|
959
|
-
rootID
|
|
956
|
+
rootID,
|
|
957
|
+
variableValue
|
|
960
958
|
};
|
|
@@ -81,12 +81,12 @@ export type ClientPluginEnterHandlers = {
|
|
|
81
81
|
/** Returns the marshaled variables for the operation */
|
|
82
82
|
marshalVariables: typeof marshalVariables;
|
|
83
83
|
};
|
|
84
|
-
/** Exit handlers are the same as enter
|
|
84
|
+
/** Exit handlers are the same as enter handlers but don't need to resolve with a specific value */
|
|
85
85
|
export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'> & {
|
|
86
86
|
resolve: (ctx: ClientPluginContext, data?: QueryResult) => void;
|
|
87
87
|
value: QueryResult;
|
|
88
88
|
};
|
|
89
|
-
/** Exit handlers are the same as enter
|
|
89
|
+
/** Exit handlers are the same as enter handlers but don't need to resolve with a specific value */
|
|
90
90
|
export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
|
|
91
91
|
error: unknown;
|
|
92
92
|
};
|
|
@@ -13,7 +13,8 @@ const cachePolicy = ({
|
|
|
13
13
|
const { policy, artifact } = ctx;
|
|
14
14
|
let useCache = false;
|
|
15
15
|
if (enabled && (artifact.kind === ArtifactKind.Query || artifact.kind === ArtifactKind.Fragment) && !ctx.cacheParams?.disableRead) {
|
|
16
|
-
|
|
16
|
+
const policyAllowsCache = policy !== CachePolicy.NetworkOnly && policy !== CachePolicy.NoCache;
|
|
17
|
+
if (policyAllowsCache) {
|
|
17
18
|
const value = localCache.read({
|
|
18
19
|
selection: artifact.selection,
|
|
19
20
|
variables: marshalVariables(ctx),
|
|
@@ -67,7 +68,7 @@ const cachePolicy = ({
|
|
|
67
68
|
return next(ctx);
|
|
68
69
|
},
|
|
69
70
|
afterNetwork(ctx, { resolve, value, marshalVariables }) {
|
|
70
|
-
if (value.source !== DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
|
|
71
|
+
if (ctx.policy !== CachePolicy.NoCache && value.source !== DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
|
|
71
72
|
if (ctx.cacheParams && "serverSideFallback" in ctx.cacheParams) {
|
|
72
73
|
serverSideFallback = ctx.cacheParams?.serverSideFallback ?? serverSideFallback;
|
|
73
74
|
}
|
|
@@ -140,7 +140,14 @@ function offsetHandlers({
|
|
|
140
140
|
fetchUpdate: parentFetchUpdate,
|
|
141
141
|
getSession
|
|
142
142
|
}) {
|
|
143
|
-
let
|
|
143
|
+
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
144
|
+
let getOffset = () => {
|
|
145
|
+
let offset = artifact.refetch?.start || countPage(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
|
|
146
|
+
if (isSinglePage) {
|
|
147
|
+
offset += getVariables()?.offset ?? 0;
|
|
148
|
+
}
|
|
149
|
+
return offset;
|
|
150
|
+
};
|
|
144
151
|
let currentOffset = getOffset() ?? 0;
|
|
145
152
|
return {
|
|
146
153
|
loadNextPage: async ({
|
|
@@ -159,7 +166,6 @@ function offsetHandlers({
|
|
|
159
166
|
if (!queryVariables.limit && !artifact.refetch.pageSize) {
|
|
160
167
|
throw missingPageSizeError("loadNextPage");
|
|
161
168
|
}
|
|
162
|
-
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
163
169
|
const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
|
|
164
170
|
await targetFetch({
|
|
165
171
|
variables: queryVariables,
|
|
@@ -4,6 +4,7 @@ export declare const CachePolicy: {
|
|
|
4
4
|
readonly CacheOnly: "CacheOnly";
|
|
5
5
|
readonly NetworkOnly: "NetworkOnly";
|
|
6
6
|
readonly CacheAndNetwork: "CacheAndNetwork";
|
|
7
|
+
readonly NoCache: "NoCache";
|
|
7
8
|
};
|
|
8
9
|
export type CachePolicies = ValuesOf<typeof CachePolicy>;
|
|
9
10
|
export declare const PaginateMode: {
|
|
@@ -70,6 +71,7 @@ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
|
|
|
70
71
|
export type InputObject = {
|
|
71
72
|
fields: Record<string, string>;
|
|
72
73
|
types: Record<string, Record<string, string>>;
|
|
74
|
+
defaults: Record<string, any>;
|
|
73
75
|
};
|
|
74
76
|
export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
|
|
75
77
|
name: string;
|