houdini-svelte 1.1.2 → 1.1.4-react.0
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 +261 -225
- package/build/plugin-esm/index.js +261 -225
- package/build/preprocess-cjs/index.js +272 -225
- package/build/preprocess-esm/index.js +272 -225
- package/build/runtime/stores/index.d.ts +1 -1
- package/build/runtime/stores/pagination/fragment.d.ts +4 -7
- package/build/runtime/stores/pagination/query.d.ts +3 -4
- package/build/runtime/stores/query.d.ts +2 -54
- package/build/runtime/types.d.ts +40 -28
- package/build/runtime-cjs/stores/index.d.ts +1 -1
- package/build/runtime-cjs/stores/pagination/fragment.d.ts +4 -7
- package/build/runtime-cjs/stores/pagination/fragment.js +6 -9
- package/build/runtime-cjs/stores/pagination/query.d.ts +3 -4
- package/build/runtime-cjs/stores/pagination/query.js +28 -22
- package/build/runtime-cjs/stores/query.d.ts +2 -54
- package/build/runtime-cjs/types.d.ts +40 -28
- package/build/runtime-esm/stores/index.d.ts +1 -1
- package/build/runtime-esm/stores/pagination/fragment.d.ts +4 -7
- package/build/runtime-esm/stores/pagination/fragment.js +4 -7
- package/build/runtime-esm/stores/pagination/query.d.ts +3 -4
- package/build/runtime-esm/stores/pagination/query.js +23 -17
- package/build/runtime-esm/stores/query.d.ts +2 -54
- package/build/runtime-esm/types.d.ts +40 -28
- package/build/test-cjs/index.js +601 -491
- package/build/test-esm/index.js +601 -491
- package/package.json +2 -2
- package/build/runtime/stores/pagination/cursor.d.ts +0 -13
- package/build/runtime/stores/pagination/fetch.d.ts +0 -3
- package/build/runtime/stores/pagination/offset.d.ts +0 -20
- package/build/runtime/stores/pagination/pageInfo.d.ts +0 -13
- package/build/runtime-cjs/stores/pagination/cursor.d.ts +0 -13
- package/build/runtime-cjs/stores/pagination/cursor.js +0 -191
- package/build/runtime-cjs/stores/pagination/fetch.d.ts +0 -3
- package/build/runtime-cjs/stores/pagination/fetch.js +0 -16
- package/build/runtime-cjs/stores/pagination/offset.d.ts +0 -20
- package/build/runtime-cjs/stores/pagination/offset.js +0 -89
- package/build/runtime-cjs/stores/pagination/pageInfo.d.ts +0 -13
- package/build/runtime-cjs/stores/pagination/pageInfo.js +0 -79
- package/build/runtime-esm/stores/pagination/cursor.d.ts +0 -13
- package/build/runtime-esm/stores/pagination/cursor.js +0 -167
- package/build/runtime-esm/stores/pagination/fetch.d.ts +0 -3
- package/build/runtime-esm/stores/pagination/fetch.js +0 -0
- package/build/runtime-esm/stores/pagination/offset.d.ts +0 -20
- package/build/runtime-esm/stores/pagination/offset.js +0 -65
- package/build/runtime-esm/stores/pagination/pageInfo.d.ts +0 -13
- package/build/runtime-esm/stores/pagination/pageInfo.js +0 -52
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
1
|
+
import type { GraphQLObject, QueryArtifact, QueryResult, CursorHandlers, OffsetHandlers, PageInfo } from '$houdini/runtime/lib/types';
|
|
2
2
|
import type { Subscriber } from 'svelte/store';
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
3
|
+
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../../types';
|
|
4
|
+
import { StoreConfig } from '../query';
|
|
5
5
|
import { QueryStore } from '../query';
|
|
6
|
-
import { type PageInfo } from './pageInfo';
|
|
7
6
|
export type CursorStoreResult<_Data extends GraphQLObject, _Input extends {}> = QueryResult<_Data, _Input> & {
|
|
8
7
|
pageInfo: PageInfo;
|
|
9
8
|
};
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
+
import { extractPageInfo } from "$houdini/runtime/lib/pageInfo";
|
|
2
|
+
import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination";
|
|
1
3
|
import { get, derived } from "svelte/store";
|
|
2
4
|
import { getClient, initClient } from "../../client";
|
|
5
|
+
import { getSession } from "../../session";
|
|
3
6
|
import { QueryStore } from "../query";
|
|
4
|
-
import { cursorHandlers } from "./cursor";
|
|
5
|
-
import { offsetHandlers } from "./offset";
|
|
6
|
-
import { extractPageInfo } from "./pageInfo";
|
|
7
7
|
class QueryStoreCursor extends QueryStore {
|
|
8
8
|
paginated = true;
|
|
9
9
|
constructor(config) {
|
|
10
10
|
super(config);
|
|
11
11
|
}
|
|
12
12
|
#_handlers = null;
|
|
13
|
-
|
|
13
|
+
async #handlers() {
|
|
14
14
|
if (this.#_handlers) {
|
|
15
15
|
return this.#_handlers;
|
|
16
16
|
}
|
|
17
|
+
await initClient();
|
|
17
18
|
const paginationObserver = getClient().observe({
|
|
18
19
|
artifact: this.artifact
|
|
19
20
|
});
|
|
20
21
|
this.#_handlers = cursorHandlers({
|
|
21
22
|
artifact: this.artifact,
|
|
22
|
-
initialValue: get(this.observer).data,
|
|
23
23
|
getState: () => get(this.observer).data,
|
|
24
24
|
getVariables: () => get(this.observer).variables,
|
|
25
25
|
storeName: this.name,
|
|
26
26
|
fetch: super.fetch.bind(this),
|
|
27
|
+
getSession,
|
|
27
28
|
fetchUpdate: async (args, updates) => {
|
|
28
|
-
await initClient();
|
|
29
29
|
return paginationObserver.send({
|
|
30
30
|
...args,
|
|
31
|
-
variables: {
|
|
32
|
-
...args?.variables
|
|
33
|
-
},
|
|
34
31
|
cacheParams: {
|
|
35
|
-
applyUpdates: updates
|
|
32
|
+
applyUpdates: updates,
|
|
33
|
+
disableSubscriptions: true,
|
|
34
|
+
...args?.cacheParams
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
37
|
}
|
|
@@ -40,13 +39,16 @@ class QueryStoreCursor extends QueryStore {
|
|
|
40
39
|
return this.#_handlers;
|
|
41
40
|
}
|
|
42
41
|
async fetch(args) {
|
|
43
|
-
|
|
42
|
+
const handlers = await this.#handlers();
|
|
43
|
+
return await handlers.fetch.call(this, args);
|
|
44
44
|
}
|
|
45
45
|
async loadPreviousPage(args) {
|
|
46
|
-
|
|
46
|
+
const handlers = await this.#handlers();
|
|
47
|
+
return await handlers.loadPreviousPage(args);
|
|
47
48
|
}
|
|
48
49
|
async loadNextPage(args) {
|
|
49
|
-
|
|
50
|
+
const handlers = await this.#handlers();
|
|
51
|
+
return await handlers.loadNextPage(args);
|
|
50
52
|
}
|
|
51
53
|
subscribe(run, invalidate) {
|
|
52
54
|
const combined = derived([{ subscribe: super.subscribe.bind(this) }], ([$parent]) => {
|
|
@@ -61,16 +63,19 @@ class QueryStoreCursor extends QueryStore {
|
|
|
61
63
|
class QueryStoreOffset extends QueryStore {
|
|
62
64
|
paginated = true;
|
|
63
65
|
async loadNextPage(args) {
|
|
64
|
-
|
|
66
|
+
const handlers = await this.#handlers();
|
|
67
|
+
return await handlers.loadNextPage.call(this, args);
|
|
65
68
|
}
|
|
66
|
-
fetch(args) {
|
|
67
|
-
|
|
69
|
+
async fetch(args) {
|
|
70
|
+
const handlers = await this.#handlers();
|
|
71
|
+
return await handlers.fetch.call(this, args);
|
|
68
72
|
}
|
|
69
73
|
#_handlers = null;
|
|
70
|
-
|
|
74
|
+
async #handlers() {
|
|
71
75
|
if (this.#_handlers) {
|
|
72
76
|
return this.#_handlers;
|
|
73
77
|
}
|
|
78
|
+
await initClient();
|
|
74
79
|
const paginationObserver = getClient().observe({
|
|
75
80
|
artifact: this.artifact
|
|
76
81
|
});
|
|
@@ -80,6 +85,7 @@ class QueryStoreOffset extends QueryStore {
|
|
|
80
85
|
fetch: super.fetch,
|
|
81
86
|
getState: () => get(this.observer).data,
|
|
82
87
|
getVariables: () => get(this.observer).variables,
|
|
88
|
+
getSession,
|
|
83
89
|
fetchUpdate: async (args) => {
|
|
84
90
|
await initClient();
|
|
85
91
|
return paginationObserver.send({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
|
|
2
|
-
import type { GraphQLObject,
|
|
3
|
-
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { GraphQLObject, MutationArtifact, QueryArtifact, QueryResult, CachePolicies } from '$houdini/runtime/lib/types';
|
|
4
3
|
import type { PluginArtifactData } from '../../plugin/artifactData';
|
|
4
|
+
import type { ClientFetchParams, LoadEventFetchParams, QueryStoreFetchParams, RequestEventFetchParams } from '../types';
|
|
5
5
|
import { BaseStore } from './base';
|
|
6
6
|
export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> extends BaseStore<_Data, _Input, QueryArtifact> {
|
|
7
7
|
variables: boolean;
|
|
@@ -31,55 +31,3 @@ export declare function fetchParams<_Data extends GraphQLObject, _Input>(artifac
|
|
|
31
31
|
policy: CachePolicies | undefined;
|
|
32
32
|
params: QueryStoreFetchParams<_Data, _Input>;
|
|
33
33
|
}>;
|
|
34
|
-
type FetchGlobalParams<_Data extends GraphQLObject, _Input> = {
|
|
35
|
-
variables?: _Input;
|
|
36
|
-
/**
|
|
37
|
-
* The policy to use when performing the fetch. If set to CachePolicy.NetworkOnly,
|
|
38
|
-
* a request will always be sent, even if the variables are the same as the last call
|
|
39
|
-
* to fetch.
|
|
40
|
-
*/
|
|
41
|
-
policy?: CachePolicies;
|
|
42
|
-
/**
|
|
43
|
-
* An object that will be passed to the fetch function.
|
|
44
|
-
* You can do what you want with it!
|
|
45
|
-
*/
|
|
46
|
-
metadata?: App.Metadata;
|
|
47
|
-
/**
|
|
48
|
-
* Set to true if you want the promise to pause while it's resolving.
|
|
49
|
-
* Only enable this if you know what you are doing. This will cause route
|
|
50
|
-
* transitions to pause while loading data.
|
|
51
|
-
*/
|
|
52
|
-
blocking?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* A function to call after the fetch happens (whether fake or not)
|
|
55
|
-
*/
|
|
56
|
-
then?: (val: _Data | null) => void | Promise<void>;
|
|
57
|
-
};
|
|
58
|
-
export type LoadEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
59
|
-
/**
|
|
60
|
-
* Directly the `even` param coming from the `load` function
|
|
61
|
-
*/
|
|
62
|
-
event?: LoadEvent;
|
|
63
|
-
};
|
|
64
|
-
export type RequestEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
65
|
-
/**
|
|
66
|
-
* A RequestEvent should be provided when the store is being used in an endpoint.
|
|
67
|
-
* When this happens, fetch also needs to be provided
|
|
68
|
-
*/
|
|
69
|
-
event?: RequestEvent;
|
|
70
|
-
/**
|
|
71
|
-
* The fetch function to use when using this store in an endpoint.
|
|
72
|
-
*/
|
|
73
|
-
fetch?: LoadEvent['fetch'];
|
|
74
|
-
};
|
|
75
|
-
export type ClientFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
76
|
-
/**
|
|
77
|
-
* An object containing all of the current info necessary for a
|
|
78
|
-
* client-side fetch. Must be called in component initialization with
|
|
79
|
-
* something like this: `const context = getHoudiniFetchContext()`
|
|
80
|
-
*/
|
|
81
|
-
context?: HoudiniFetchContext;
|
|
82
|
-
};
|
|
83
|
-
export type QueryStoreFetchParams<_Data extends GraphQLObject, _Input> = QueryStoreLoadParams<_Data, _Input> | ClientFetchParams<_Data, _Input>;
|
|
84
|
-
export type QueryStoreLoadParams<_Data extends GraphQLObject, _Input> = LoadEventFetchParams<_Data, _Input> | RequestEventFetchParams<_Data, _Input>;
|
|
85
|
-
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject } from '$houdini/runtime/lib/types';
|
|
2
|
-
import type { LoadEvent } from '@sveltejs/kit';
|
|
3
|
-
import type { Readable
|
|
4
|
-
import type { QueryStoreFetchParams } from './stores';
|
|
5
|
-
import type { PageInfo } from './stores/pagination/pageInfo';
|
|
1
|
+
import type { FetchQueryResult, CompiledFragmentKind, QueryResult, GraphQLObject, CursorHandlers, OffsetHandlers, PageInfo, HoudiniFetchContext, FetchParams } from '$houdini/runtime/lib/types';
|
|
2
|
+
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
3
|
+
import type { Readable } from 'svelte/store';
|
|
6
4
|
export type QueryInputs<_Data> = FetchQueryResult<_Data> & {
|
|
7
5
|
variables: {
|
|
8
6
|
[key: string]: any;
|
|
@@ -54,29 +52,43 @@ export type OffsetFragmentStoreInstance<_Data extends GraphQLObject, _Input> = {
|
|
|
54
52
|
subscribe: Readable<Reshape<_Data, _Input>>['subscribe'];
|
|
55
53
|
fetching: Readable<boolean>;
|
|
56
54
|
} & OffsetHandlers<_Data, _Input>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
metadata?: {};
|
|
69
|
-
}) => Promise<void>;
|
|
70
|
-
pageInfo: Writable<PageInfo>;
|
|
71
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
55
|
+
type FetchGlobalParams<_Data extends GraphQLObject, _Input> = FetchParams<_Input> & {
|
|
56
|
+
/**
|
|
57
|
+
* Set to true if you want the promise to pause while it's resolving.
|
|
58
|
+
* Only enable this if you know what you are doing. This will cause route
|
|
59
|
+
* transitions to pause while loading data.
|
|
60
|
+
*/
|
|
61
|
+
blocking?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* A function to call after the fetch happens (whether fake or not)
|
|
64
|
+
*/
|
|
65
|
+
then?: (val: _Data | null) => void | Promise<void>;
|
|
72
66
|
};
|
|
73
|
-
export type
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
fetch?: typeof globalThis.fetch;
|
|
79
|
-
}) => Promise<void>;
|
|
80
|
-
fetch(args?: QueryStoreFetchParams<_Data, _Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
67
|
+
export type LoadEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
68
|
+
/**
|
|
69
|
+
* Directly the `even` param coming from the `load` function
|
|
70
|
+
*/
|
|
71
|
+
event?: LoadEvent;
|
|
81
72
|
};
|
|
73
|
+
export type RequestEventFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
74
|
+
/**
|
|
75
|
+
* A RequestEvent should be provided when the store is being used in an endpoint.
|
|
76
|
+
* When this happens, fetch also needs to be provided
|
|
77
|
+
*/
|
|
78
|
+
event?: RequestEvent;
|
|
79
|
+
/**
|
|
80
|
+
* The fetch function to use when using this store in an endpoint.
|
|
81
|
+
*/
|
|
82
|
+
fetch?: LoadEvent['fetch'];
|
|
83
|
+
};
|
|
84
|
+
export type ClientFetchParams<_Data extends GraphQLObject, _Input> = FetchGlobalParams<_Data, _Input> & {
|
|
85
|
+
/**
|
|
86
|
+
* An object containing all of the current info necessary for a
|
|
87
|
+
* client-side fetch. Must be called in component initialization with
|
|
88
|
+
* something like this: `const context = getHoudiniFetchContext()`
|
|
89
|
+
*/
|
|
90
|
+
context?: HoudiniFetchContext;
|
|
91
|
+
};
|
|
92
|
+
export type QueryStoreFetchParams<_Data extends GraphQLObject, _Input> = QueryStoreLoadParams<_Data, _Input> | ClientFetchParams<_Data, _Input>;
|
|
93
|
+
export type QueryStoreLoadParams<_Data extends GraphQLObject, _Input> = LoadEventFetchParams<_Data, _Input> | RequestEventFetchParams<_Data, _Input>;
|
|
82
94
|
export {};
|