houdini-svelte 2.1.9 → 2.1.11
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/plugin-cjs/index.js +7 -5
- package/build/plugin-esm/index.js +7 -5
- package/build/preprocess-cjs/index.js +4 -4
- package/build/preprocess-esm/index.js +4 -4
- package/build/runtime/client.d.ts +1 -0
- package/build/runtime/fragments.d.ts +1 -1
- package/build/runtime/stores/fragment.d.ts +58 -2
- package/build/runtime/stores/index.d.ts +2 -3
- package/build/runtime/stores/query.d.ts +27 -1
- package/build/runtime-cjs/client.d.ts +1 -0
- package/build/runtime-cjs/client.js +22 -5
- package/build/runtime-cjs/fragments.d.ts +1 -1
- package/build/runtime-cjs/stores/base.js +5 -0
- package/build/runtime-cjs/stores/fragment.d.ts +58 -2
- package/build/runtime-cjs/stores/fragment.js +184 -2
- package/build/runtime-cjs/stores/index.d.ts +2 -3
- package/build/runtime-cjs/stores/index.js +9 -3
- package/build/runtime-cjs/stores/mutation.js +2 -0
- package/build/runtime-cjs/stores/query.d.ts +27 -1
- package/build/runtime-cjs/stores/query.js +123 -1
- package/build/runtime-cjs/stores/subscription.js +3 -0
- package/build/runtime-esm/client.d.ts +1 -0
- package/build/runtime-esm/client.js +18 -2
- package/build/runtime-esm/fragments.d.ts +1 -1
- package/build/runtime-esm/stores/base.js +6 -1
- package/build/runtime-esm/stores/fragment.d.ts +58 -2
- package/build/runtime-esm/stores/fragment.js +183 -3
- package/build/runtime-esm/stores/index.d.ts +2 -3
- package/build/runtime-esm/stores/index.js +6 -3
- package/build/runtime-esm/stores/mutation.js +2 -0
- package/build/runtime-esm/stores/query.d.ts +27 -1
- package/build/runtime-esm/stores/query.js +124 -4
- package/build/runtime-esm/stores/subscription.js +3 -0
- package/build/test-cjs/index.js +7 -5
- package/build/test-esm/index.js +7 -5
- package/package.json +1 -1
- package/build/runtime/stores/pagination/fragment.d.ts +0 -58
- package/build/runtime/stores/pagination/index.d.ts +0 -2
- package/build/runtime/stores/pagination/query.d.ts +0 -30
- package/build/runtime-cjs/stores/pagination/fragment.d.ts +0 -58
- package/build/runtime-cjs/stores/pagination/fragment.js +0 -207
- package/build/runtime-cjs/stores/pagination/index.d.ts +0 -2
- package/build/runtime-cjs/stores/pagination/index.js +0 -35
- package/build/runtime-cjs/stores/pagination/query.d.ts +0 -30
- package/build/runtime-cjs/stores/pagination/query.js +0 -147
- package/build/runtime-esm/stores/pagination/fragment.d.ts +0 -58
- package/build/runtime-esm/stores/pagination/fragment.js +0 -182
- package/build/runtime-esm/stores/pagination/index.d.ts +0 -2
- package/build/runtime-esm/stores/pagination/index.js +0 -8
- package/build/runtime-esm/stores/pagination/query.d.ts +0 -30
- package/build/runtime-esm/stores/pagination/query.js +0 -122
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
|
-
import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
3
|
-
import type { Subscriber } from 'svelte/store';
|
|
4
|
-
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
|
|
5
|
-
import type { StoreConfig } from '../query';
|
|
6
|
-
import { QueryStore } from '../query';
|
|
7
|
-
export type CursorStoreResult<_Data extends GraphQLObject, _Input extends GraphQLVariables> = QueryResult<_Data, _Input> & {
|
|
8
|
-
pageInfo: PageInfo;
|
|
9
|
-
};
|
|
10
|
-
export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
|
|
11
|
-
#private;
|
|
12
|
-
paginated: boolean;
|
|
13
|
-
constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
|
|
14
|
-
fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
15
|
-
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
16
|
-
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
17
|
-
fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
18
|
-
loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<QueryResult<_Data, _Input>>;
|
|
19
|
-
loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<QueryResult<_Data, _Input>>;
|
|
20
|
-
subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
|
|
21
|
-
}
|
|
22
|
-
export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
|
|
23
|
-
#private;
|
|
24
|
-
paginated: boolean;
|
|
25
|
-
loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
|
|
26
|
-
fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
27
|
-
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
28
|
-
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
29
|
-
fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
30
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var query_exports = {};
|
|
20
|
-
__export(query_exports, {
|
|
21
|
-
QueryStoreCursor: () => QueryStoreCursor,
|
|
22
|
-
QueryStoreOffset: () => QueryStoreOffset
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(query_exports);
|
|
25
|
-
var import_pageInfo = require("$houdini/runtime/lib/pageInfo");
|
|
26
|
-
var import_pagination = require("$houdini/runtime/lib/pagination");
|
|
27
|
-
var import_store = require("svelte/store");
|
|
28
|
-
var import_client = require("../../client");
|
|
29
|
-
var import_session = require("../../session");
|
|
30
|
-
var import_query = require("../query");
|
|
31
|
-
class QueryStoreCursor extends import_query.QueryStore {
|
|
32
|
-
paginated = true;
|
|
33
|
-
constructor(config) {
|
|
34
|
-
super(config);
|
|
35
|
-
}
|
|
36
|
-
#_handlers = null;
|
|
37
|
-
async #handlers() {
|
|
38
|
-
if (this.#_handlers) {
|
|
39
|
-
return this.#_handlers;
|
|
40
|
-
}
|
|
41
|
-
const paginationObserver = (0, import_client.getClient)().observe({
|
|
42
|
-
artifact: this.artifact
|
|
43
|
-
});
|
|
44
|
-
this.#_handlers = (0, import_pagination.cursorHandlers)({
|
|
45
|
-
artifact: this.artifact,
|
|
46
|
-
getState: () => (0, import_store.get)(this.observer).data,
|
|
47
|
-
getVariables: () => (0, import_store.get)(this.observer).variables,
|
|
48
|
-
fetch: super.fetch.bind(this),
|
|
49
|
-
getSession: import_session.getSession,
|
|
50
|
-
fetchUpdate: async (args, updates) => {
|
|
51
|
-
return paginationObserver.send({
|
|
52
|
-
...args,
|
|
53
|
-
cacheParams: {
|
|
54
|
-
applyUpdates: updates,
|
|
55
|
-
disableSubscriptions: true,
|
|
56
|
-
...args?.cacheParams
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return this.#_handlers;
|
|
62
|
-
}
|
|
63
|
-
async fetch(args) {
|
|
64
|
-
const handlers = await this.#handlers();
|
|
65
|
-
return await handlers.fetch.call(this, args);
|
|
66
|
-
}
|
|
67
|
-
async loadPreviousPage(args) {
|
|
68
|
-
const handlers = await this.#handlers();
|
|
69
|
-
try {
|
|
70
|
-
return await handlers.loadPreviousPage(args);
|
|
71
|
-
} catch (e) {
|
|
72
|
-
const err = e;
|
|
73
|
-
if (err.name === "AbortError") {
|
|
74
|
-
return (0, import_store.get)(this.observer);
|
|
75
|
-
} else {
|
|
76
|
-
throw err;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async loadNextPage(args) {
|
|
81
|
-
const handlers = await this.#handlers();
|
|
82
|
-
try {
|
|
83
|
-
return await handlers.loadNextPage(args);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
const err = e;
|
|
86
|
-
if (err.name === "AbortError") {
|
|
87
|
-
return (0, import_store.get)(this.observer);
|
|
88
|
-
} else {
|
|
89
|
-
throw err;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
subscribe(run, invalidate) {
|
|
94
|
-
const combined = (0, import_store.derived)([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
|
|
95
|
-
return {
|
|
96
|
-
...$parent,
|
|
97
|
-
pageInfo: (0, import_pageInfo.extractPageInfo)($parent.data, this.artifact.refetch.path)
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
return combined.subscribe(run, invalidate);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
class QueryStoreOffset extends import_query.QueryStore {
|
|
104
|
-
paginated = true;
|
|
105
|
-
async loadNextPage(args) {
|
|
106
|
-
const handlers = await this.#handlers();
|
|
107
|
-
return await handlers.loadNextPage.call(this, args);
|
|
108
|
-
}
|
|
109
|
-
async fetch(args) {
|
|
110
|
-
const handlers = await this.#handlers();
|
|
111
|
-
return await handlers.fetch.call(this, args);
|
|
112
|
-
}
|
|
113
|
-
#_handlers = null;
|
|
114
|
-
async #handlers() {
|
|
115
|
-
if (this.#_handlers) {
|
|
116
|
-
return this.#_handlers;
|
|
117
|
-
}
|
|
118
|
-
const paginationObserver = (0, import_client.getClient)().observe({
|
|
119
|
-
artifact: this.artifact
|
|
120
|
-
});
|
|
121
|
-
this.#_handlers = (0, import_pagination.offsetHandlers)({
|
|
122
|
-
artifact: this.artifact,
|
|
123
|
-
storeName: this.name,
|
|
124
|
-
fetch: super.fetch.bind(this),
|
|
125
|
-
getState: () => (0, import_store.get)(this.observer).data,
|
|
126
|
-
getVariables: () => (0, import_store.get)(this.observer).variables,
|
|
127
|
-
getSession: import_session.getSession,
|
|
128
|
-
fetchUpdate: async (args) => {
|
|
129
|
-
return paginationObserver.send({
|
|
130
|
-
...args,
|
|
131
|
-
variables: {
|
|
132
|
-
...args?.variables
|
|
133
|
-
},
|
|
134
|
-
cacheParams: {
|
|
135
|
-
applyUpdates: ["append"]
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
return this.#_handlers;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
-
0 && (module.exports = {
|
|
145
|
-
QueryStoreCursor,
|
|
146
|
-
QueryStoreOffset
|
|
147
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
|
-
import type { DocumentStore } from '$houdini/runtime/client';
|
|
3
|
-
import type { FragmentArtifact, GraphQLObject, HoudiniFetchContext, QueryArtifact, PageInfo, CursorHandlers, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
4
|
-
import type { Readable, Subscriber } from 'svelte/store';
|
|
5
|
-
import type { OffsetFragmentStoreInstance } from '../../types';
|
|
6
|
-
import type { StoreConfig } from '../query';
|
|
7
|
-
type FragmentStoreConfig<_Data extends GraphQLObject, _Input> = StoreConfig<_Data, _Input, FragmentArtifact> & {
|
|
8
|
-
paginationArtifact: QueryArtifact;
|
|
9
|
-
};
|
|
10
|
-
declare class BasePaginatedFragmentStore<_Data extends GraphQLObject, _Input> {
|
|
11
|
-
paginated: boolean;
|
|
12
|
-
protected paginationArtifact: QueryArtifact;
|
|
13
|
-
name: string;
|
|
14
|
-
kind: "HoudiniFragment";
|
|
15
|
-
artifact: FragmentArtifact;
|
|
16
|
-
constructor(config: FragmentStoreConfig<_Data, _Input>);
|
|
17
|
-
protected queryVariables(getState: () => _Data | null): _Input;
|
|
18
|
-
}
|
|
19
|
-
export declare class FragmentStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
|
|
20
|
-
get(initialValue: _Data | null): {
|
|
21
|
-
kind: "HoudiniFragment";
|
|
22
|
-
subscribe: (run: Subscriber<FragmentPaginatedResult<_Data, {
|
|
23
|
-
pageInfo: PageInfo;
|
|
24
|
-
}>>, invalidate?: ((value?: FragmentPaginatedResult<_Data, {
|
|
25
|
-
pageInfo: PageInfo;
|
|
26
|
-
}> | undefined) => void) | undefined) => (() => void);
|
|
27
|
-
fetch: (args?: import("$houdini/runtime/lib/types").FetchParams<_Input> | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
28
|
-
loadNextPage: (args?: {
|
|
29
|
-
first?: number | undefined;
|
|
30
|
-
after?: string | undefined;
|
|
31
|
-
fetch?: typeof fetch | undefined;
|
|
32
|
-
metadata?: {} | undefined;
|
|
33
|
-
} | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
34
|
-
loadPreviousPage: (args?: {
|
|
35
|
-
last?: number | undefined;
|
|
36
|
-
before?: string | undefined;
|
|
37
|
-
fetch?: typeof fetch | undefined;
|
|
38
|
-
metadata?: {} | undefined;
|
|
39
|
-
} | undefined) => Promise<import("$houdini/runtime/lib/types").QueryResult<_Data, _Input>>;
|
|
40
|
-
};
|
|
41
|
-
protected storeHandlers(observer: DocumentStore<_Data, _Input>, initialValue: _Data | null, getState: () => _Data | null, getVariables: () => NonNullable<_Input>): CursorHandlers<_Data, _Input>;
|
|
42
|
-
}
|
|
43
|
-
export declare class FragmentStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends BasePaginatedFragmentStore<_Data, _Input> {
|
|
44
|
-
get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input>;
|
|
45
|
-
}
|
|
46
|
-
export type FragmentStorePaginated<_Data extends GraphQLObject, _Input> = Readable<{
|
|
47
|
-
data: _Data;
|
|
48
|
-
fetching: boolean;
|
|
49
|
-
pageInfo: PageInfo;
|
|
50
|
-
}> & {
|
|
51
|
-
loadNextPage(pageCount?: number, after?: string | number, houdiniContext?: HoudiniFetchContext): Promise<void>;
|
|
52
|
-
loadPreviousPage(pageCount?: number, before?: string, houdiniContext?: HoudiniFetchContext): Promise<void>;
|
|
53
|
-
};
|
|
54
|
-
export type FragmentPaginatedResult<_Data, _ExtraFields = {}> = {
|
|
55
|
-
data: _Data | null;
|
|
56
|
-
fetching: boolean;
|
|
57
|
-
} & _ExtraFields;
|
|
58
|
-
export {};
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { getCurrentConfig, keyFieldsForType } from "$houdini/runtime/lib/config";
|
|
2
|
-
import { siteURL } from "$houdini/runtime/lib/constants";
|
|
3
|
-
import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
4
|
-
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
5
|
-
import { CompiledFragmentKind } from "$houdini/runtime/lib/types";
|
|
6
|
-
import { derived, get } from "svelte/store";
|
|
7
|
-
import { getClient } from "../../client";
|
|
8
|
-
import { getSession } from "../../session";
|
|
9
|
-
import { FragmentStore } from "../fragment";
|
|
10
|
-
class BasePaginatedFragmentStore {
|
|
11
|
-
paginated = true;
|
|
12
|
-
paginationArtifact;
|
|
13
|
-
name;
|
|
14
|
-
kind = CompiledFragmentKind;
|
|
15
|
-
artifact;
|
|
16
|
-
constructor(config) {
|
|
17
|
-
this.paginationArtifact = config.paginationArtifact;
|
|
18
|
-
this.name = config.storeName;
|
|
19
|
-
this.artifact = config.artifact;
|
|
20
|
-
}
|
|
21
|
-
queryVariables(getState) {
|
|
22
|
-
const config = getCurrentConfig();
|
|
23
|
-
const { targetType } = this.paginationArtifact.refetch || {};
|
|
24
|
-
const typeConfig = config.types?.[targetType || ""];
|
|
25
|
-
if (!typeConfig) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Missing type refetch configuration for ${targetType}. For more information, see ${siteURL}/guides/pagination#paginated-fragments`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
let idVariables = {};
|
|
31
|
-
const value = getState();
|
|
32
|
-
if (typeConfig.resolve?.arguments) {
|
|
33
|
-
idVariables = typeConfig.resolve.arguments?.(value) || {};
|
|
34
|
-
} else {
|
|
35
|
-
const keys = keyFieldsForType(config, targetType || "");
|
|
36
|
-
idVariables = Object.fromEntries(keys.map((key) => [key, value[key]]));
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
...idVariables
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class FragmentStoreCursor extends BasePaginatedFragmentStore {
|
|
44
|
-
get(initialValue) {
|
|
45
|
-
const base = new FragmentStore({
|
|
46
|
-
artifact: this.artifact,
|
|
47
|
-
storeName: this.name
|
|
48
|
-
});
|
|
49
|
-
const store = base.get(initialValue);
|
|
50
|
-
const paginationStore = getClient().observe({
|
|
51
|
-
artifact: this.paginationArtifact,
|
|
52
|
-
initialValue: store.initialValue
|
|
53
|
-
});
|
|
54
|
-
const handlers = this.storeHandlers(
|
|
55
|
-
paginationStore,
|
|
56
|
-
initialValue,
|
|
57
|
-
() => get(store),
|
|
58
|
-
() => store.variables
|
|
59
|
-
);
|
|
60
|
-
const subscribe = (run, invalidate) => {
|
|
61
|
-
const combined = derived([store, paginationStore], ([$parent, $pagination]) => {
|
|
62
|
-
return {
|
|
63
|
-
...$pagination,
|
|
64
|
-
data: $parent,
|
|
65
|
-
pageInfo: extractPageInfo($parent, this.paginationArtifact.refetch.path)
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
return combined.subscribe(run, invalidate);
|
|
69
|
-
};
|
|
70
|
-
return {
|
|
71
|
-
kind: CompiledFragmentKind,
|
|
72
|
-
subscribe,
|
|
73
|
-
fetch: handlers.fetch,
|
|
74
|
-
loadNextPage: handlers.loadNextPage,
|
|
75
|
-
loadPreviousPage: handlers.loadPreviousPage
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
storeHandlers(observer, initialValue, getState, getVariables) {
|
|
79
|
-
return cursorHandlers({
|
|
80
|
-
getState,
|
|
81
|
-
getVariables,
|
|
82
|
-
artifact: this.paginationArtifact,
|
|
83
|
-
fetchUpdate: async (args, updates) => {
|
|
84
|
-
return observer.send({
|
|
85
|
-
session: await getSession(),
|
|
86
|
-
...args,
|
|
87
|
-
variables: {
|
|
88
|
-
...args?.variables,
|
|
89
|
-
...this.queryVariables(getState)
|
|
90
|
-
},
|
|
91
|
-
cacheParams: {
|
|
92
|
-
applyUpdates: updates,
|
|
93
|
-
disableSubscriptions: true
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
fetch: async (args) => {
|
|
98
|
-
return await observer.send({
|
|
99
|
-
session: await getSession(),
|
|
100
|
-
...args,
|
|
101
|
-
variables: {
|
|
102
|
-
...args?.variables,
|
|
103
|
-
...this.queryVariables(getState)
|
|
104
|
-
},
|
|
105
|
-
cacheParams: {
|
|
106
|
-
disableSubscriptions: true
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
getSession
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
class FragmentStoreOffset extends BasePaginatedFragmentStore {
|
|
115
|
-
get(initialValue) {
|
|
116
|
-
const base = new FragmentStore({
|
|
117
|
-
artifact: this.artifact,
|
|
118
|
-
storeName: this.name
|
|
119
|
-
});
|
|
120
|
-
const store = base.get(initialValue);
|
|
121
|
-
const paginationStore = getClient().observe({
|
|
122
|
-
artifact: this.paginationArtifact,
|
|
123
|
-
initialValue: store.initialValue
|
|
124
|
-
});
|
|
125
|
-
const getState = () => get(store);
|
|
126
|
-
const handlers = offsetHandlers({
|
|
127
|
-
getState,
|
|
128
|
-
getVariables: () => store.variables,
|
|
129
|
-
artifact: this.paginationArtifact,
|
|
130
|
-
fetch: async (args) => {
|
|
131
|
-
return paginationStore.send({
|
|
132
|
-
...args,
|
|
133
|
-
session: await getSession(),
|
|
134
|
-
variables: {
|
|
135
|
-
...this.queryVariables(getState),
|
|
136
|
-
...args?.variables
|
|
137
|
-
},
|
|
138
|
-
cacheParams: {
|
|
139
|
-
disableSubscriptions: true
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
},
|
|
143
|
-
fetchUpdate: async (args) => {
|
|
144
|
-
return paginationStore.send({
|
|
145
|
-
session: await getSession(),
|
|
146
|
-
...args,
|
|
147
|
-
variables: {
|
|
148
|
-
...this.queryVariables(getState),
|
|
149
|
-
...args?.variables
|
|
150
|
-
},
|
|
151
|
-
cacheParams: {
|
|
152
|
-
disableSubscriptions: true,
|
|
153
|
-
applyUpdates: ["append"]
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
},
|
|
157
|
-
getSession,
|
|
158
|
-
storeName: this.name
|
|
159
|
-
});
|
|
160
|
-
const subscribe = (run, invalidate) => {
|
|
161
|
-
const combined = derived([store, paginationStore], ([$parent, $pagination]) => {
|
|
162
|
-
return {
|
|
163
|
-
...$pagination,
|
|
164
|
-
data: $parent
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
return combined.subscribe(run, invalidate);
|
|
168
|
-
};
|
|
169
|
-
return {
|
|
170
|
-
kind: CompiledFragmentKind,
|
|
171
|
-
data: derived(paginationStore, ($value) => $value.data),
|
|
172
|
-
subscribe,
|
|
173
|
-
fetch: handlers.fetch,
|
|
174
|
-
loadNextPage: handlers.loadNextPage,
|
|
175
|
-
fetching: derived(paginationStore, ($store) => $store.fetching)
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
export {
|
|
180
|
-
FragmentStoreCursor,
|
|
181
|
-
FragmentStoreOffset
|
|
182
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
|
-
import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo, GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
3
|
-
import type { Subscriber } from 'svelte/store';
|
|
4
|
-
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
|
|
5
|
-
import type { StoreConfig } from '../query';
|
|
6
|
-
import { QueryStore } from '../query';
|
|
7
|
-
export type CursorStoreResult<_Data extends GraphQLObject, _Input extends GraphQLVariables> = QueryResult<_Data, _Input> & {
|
|
8
|
-
pageInfo: PageInfo;
|
|
9
|
-
};
|
|
10
|
-
export declare class QueryStoreCursor<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
|
|
11
|
-
#private;
|
|
12
|
-
paginated: boolean;
|
|
13
|
-
constructor(config: StoreConfig<_Data, _Input, QueryArtifact>);
|
|
14
|
-
fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
15
|
-
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
16
|
-
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
17
|
-
fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
18
|
-
loadPreviousPage(args?: Parameters<Required<CursorHandlers<_Data, _Input>>['loadPreviousPage']>[0]): Promise<QueryResult<_Data, _Input>>;
|
|
19
|
-
loadNextPage(args?: Parameters<CursorHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<QueryResult<_Data, _Input>>;
|
|
20
|
-
subscribe(run: Subscriber<CursorStoreResult<_Data, _Input>>, invalidate?: ((value?: CursorStoreResult<_Data, _Input> | undefined) => void) | undefined): () => void;
|
|
21
|
-
}
|
|
22
|
-
export declare class QueryStoreOffset<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends QueryStore<_Data, _Input> {
|
|
23
|
-
#private;
|
|
24
|
-
paginated: boolean;
|
|
25
|
-
loadNextPage(args?: Parameters<OffsetHandlers<_Data, _Input>['loadNextPage']>[0]): Promise<void>;
|
|
26
|
-
fetch(params?: RequestEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
27
|
-
fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
28
|
-
fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
29
|
-
fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
|
|
30
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
2
|
-
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
3
|
-
import { get, derived } from "svelte/store";
|
|
4
|
-
import { getClient } from "../../client";
|
|
5
|
-
import { getSession } from "../../session";
|
|
6
|
-
import { QueryStore } from "../query";
|
|
7
|
-
class QueryStoreCursor extends QueryStore {
|
|
8
|
-
paginated = true;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
super(config);
|
|
11
|
-
}
|
|
12
|
-
#_handlers = null;
|
|
13
|
-
async #handlers() {
|
|
14
|
-
if (this.#_handlers) {
|
|
15
|
-
return this.#_handlers;
|
|
16
|
-
}
|
|
17
|
-
const paginationObserver = getClient().observe({
|
|
18
|
-
artifact: this.artifact
|
|
19
|
-
});
|
|
20
|
-
this.#_handlers = cursorHandlers({
|
|
21
|
-
artifact: this.artifact,
|
|
22
|
-
getState: () => get(this.observer).data,
|
|
23
|
-
getVariables: () => get(this.observer).variables,
|
|
24
|
-
fetch: super.fetch.bind(this),
|
|
25
|
-
getSession,
|
|
26
|
-
fetchUpdate: async (args, updates) => {
|
|
27
|
-
return paginationObserver.send({
|
|
28
|
-
...args,
|
|
29
|
-
cacheParams: {
|
|
30
|
-
applyUpdates: updates,
|
|
31
|
-
disableSubscriptions: true,
|
|
32
|
-
...args?.cacheParams
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return this.#_handlers;
|
|
38
|
-
}
|
|
39
|
-
async fetch(args) {
|
|
40
|
-
const handlers = await this.#handlers();
|
|
41
|
-
return await handlers.fetch.call(this, args);
|
|
42
|
-
}
|
|
43
|
-
async loadPreviousPage(args) {
|
|
44
|
-
const handlers = await this.#handlers();
|
|
45
|
-
try {
|
|
46
|
-
return await handlers.loadPreviousPage(args);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
const err = e;
|
|
49
|
-
if (err.name === "AbortError") {
|
|
50
|
-
return get(this.observer);
|
|
51
|
-
} else {
|
|
52
|
-
throw err;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async loadNextPage(args) {
|
|
57
|
-
const handlers = await this.#handlers();
|
|
58
|
-
try {
|
|
59
|
-
return await handlers.loadNextPage(args);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
const err = e;
|
|
62
|
-
if (err.name === "AbortError") {
|
|
63
|
-
return get(this.observer);
|
|
64
|
-
} else {
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
subscribe(run, invalidate) {
|
|
70
|
-
const combined = derived([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
|
|
71
|
-
return {
|
|
72
|
-
...$parent,
|
|
73
|
-
pageInfo: extractPageInfo($parent.data, this.artifact.refetch.path)
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
return combined.subscribe(run, invalidate);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
class QueryStoreOffset extends QueryStore {
|
|
80
|
-
paginated = true;
|
|
81
|
-
async loadNextPage(args) {
|
|
82
|
-
const handlers = await this.#handlers();
|
|
83
|
-
return await handlers.loadNextPage.call(this, args);
|
|
84
|
-
}
|
|
85
|
-
async fetch(args) {
|
|
86
|
-
const handlers = await this.#handlers();
|
|
87
|
-
return await handlers.fetch.call(this, args);
|
|
88
|
-
}
|
|
89
|
-
#_handlers = null;
|
|
90
|
-
async #handlers() {
|
|
91
|
-
if (this.#_handlers) {
|
|
92
|
-
return this.#_handlers;
|
|
93
|
-
}
|
|
94
|
-
const paginationObserver = getClient().observe({
|
|
95
|
-
artifact: this.artifact
|
|
96
|
-
});
|
|
97
|
-
this.#_handlers = offsetHandlers({
|
|
98
|
-
artifact: this.artifact,
|
|
99
|
-
storeName: this.name,
|
|
100
|
-
fetch: super.fetch.bind(this),
|
|
101
|
-
getState: () => get(this.observer).data,
|
|
102
|
-
getVariables: () => get(this.observer).variables,
|
|
103
|
-
getSession,
|
|
104
|
-
fetchUpdate: async (args) => {
|
|
105
|
-
return paginationObserver.send({
|
|
106
|
-
...args,
|
|
107
|
-
variables: {
|
|
108
|
-
...args?.variables
|
|
109
|
-
},
|
|
110
|
-
cacheParams: {
|
|
111
|
-
applyUpdates: ["append"]
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return this.#_handlers;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
export {
|
|
120
|
-
QueryStoreCursor,
|
|
121
|
-
QueryStoreOffset
|
|
122
|
-
};
|