houdini-svelte 0.17.12 → 0.17.14
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 +76 -13
- package/build/plugin-esm/index.js +76 -13
- package/build/runtime/stores/pagination/query.d.ts +1 -1
- package/build/runtime/stores/query.d.ts +1 -2
- package/build/runtime-cjs/stores/pagination/query.d.ts +1 -1
- package/build/runtime-cjs/stores/query.d.ts +1 -2
- package/build/runtime-cjs/stores/query.js +27 -12
- package/build/runtime-esm/stores/pagination/query.d.ts +1 -1
- package/build/runtime-esm/stores/query.d.ts +1 -2
- package/build/runtime-esm/stores/query.js +28 -11
- package/build/test-cjs/index.js +76 -13
- package/build/test-esm/index.js +76 -13
- package/package.json +6 -6
|
@@ -30803,10 +30803,10 @@ var require_main5 = __commonJS({
|
|
|
30803
30803
|
}
|
|
30804
30804
|
});
|
|
30805
30805
|
|
|
30806
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30806
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js
|
|
30807
30807
|
var HttpError, Redirect, ValidationError;
|
|
30808
30808
|
var init_control = __esm({
|
|
30809
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30809
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js"() {
|
|
30810
30810
|
HttpError = class {
|
|
30811
30811
|
constructor(status, body) {
|
|
30812
30812
|
this.status = status;
|
|
@@ -30837,7 +30837,7 @@ var init_control = __esm({
|
|
|
30837
30837
|
}
|
|
30838
30838
|
});
|
|
30839
30839
|
|
|
30840
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30840
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js
|
|
30841
30841
|
var exports_exports = {};
|
|
30842
30842
|
__export(exports_exports, {
|
|
30843
30843
|
error: () => error2,
|
|
@@ -30846,10 +30846,13 @@ __export(exports_exports, {
|
|
|
30846
30846
|
redirect: () => redirect
|
|
30847
30847
|
});
|
|
30848
30848
|
function error2(status, message) {
|
|
30849
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 400 || status > 599)) {
|
|
30850
|
+
throw new Error(`HTTP error status codes must be between 400 and 599 \u2014 ${status} is invalid`);
|
|
30851
|
+
}
|
|
30849
30852
|
return new HttpError(status, message);
|
|
30850
30853
|
}
|
|
30851
30854
|
function redirect(status, location) {
|
|
30852
|
-
if (isNaN(status) || status < 300 || status > 308) {
|
|
30855
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 300 || status > 308)) {
|
|
30853
30856
|
throw new Error("Invalid status code");
|
|
30854
30857
|
}
|
|
30855
30858
|
return new Redirect(status, location);
|
|
@@ -30868,7 +30871,7 @@ function invalid(status, data2) {
|
|
|
30868
30871
|
return new ValidationError(status, data2);
|
|
30869
30872
|
}
|
|
30870
30873
|
var init_exports = __esm({
|
|
30871
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30874
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js"() {
|
|
30872
30875
|
init_control();
|
|
30873
30876
|
}
|
|
30874
30877
|
});
|
|
@@ -179958,7 +179961,7 @@ type AfterLoadData = {
|
|
|
179958
179961
|
};
|
|
179959
179962
|
|
|
179960
179963
|
export type AfterLoadEvent = {
|
|
179961
|
-
event:
|
|
179964
|
+
event: ${type}LoadEvent
|
|
179962
179965
|
data: AfterLoadData
|
|
179963
179966
|
input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
|
|
179964
179967
|
};
|
|
@@ -179972,7 +179975,7 @@ function internal_append_afterLoad(queries) {
|
|
|
179972
179975
|
}
|
|
179973
179976
|
function append_beforeLoad(beforeLoad, type) {
|
|
179974
179977
|
return beforeLoad ? `
|
|
179975
|
-
export type BeforeLoadEvent =
|
|
179978
|
+
export type BeforeLoadEvent = ${type}LoadEvent;
|
|
179976
179979
|
type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
|
|
179977
179980
|
` : "";
|
|
179978
179981
|
}
|
|
@@ -180127,8 +180130,6 @@ async function queryStore({ config: config2, plugin_root }, doc) {
|
|
|
180127
180130
|
const storeData = `${statement}
|
|
180128
180131
|
import artifact from '$houdini/artifacts/${artifactName}'
|
|
180129
180132
|
|
|
180130
|
-
// create the query store
|
|
180131
|
-
|
|
180132
180133
|
export class ${storeName} extends ${store_class} {
|
|
180133
180134
|
constructor() {
|
|
180134
180135
|
super({
|
|
@@ -180158,16 +180159,78 @@ export default ${globalStoreName}
|
|
|
180158
180159
|
const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
|
|
180159
180160
|
|
|
180160
180161
|
export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
|
|
180162
|
+
/**
|
|
180163
|
+
* ### Route Loads
|
|
180164
|
+
* In a route's load function, manually instantiating a store can be used to look at the result:
|
|
180165
|
+
*
|
|
180166
|
+
* \`\`\`js
|
|
180167
|
+
* export async function load(event) {
|
|
180168
|
+
* const store = new ${storeName}Store()
|
|
180169
|
+
* const { data } = await store.fetch({event})
|
|
180170
|
+
* console.log('do something with', data)
|
|
180171
|
+
*
|
|
180172
|
+
* return {
|
|
180173
|
+
* ${storeName}: store,
|
|
180174
|
+
* }
|
|
180175
|
+
* }
|
|
180176
|
+
*
|
|
180177
|
+
* \`\`\`
|
|
180178
|
+
*
|
|
180179
|
+
* ### Client Side Loading
|
|
180180
|
+
* When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
|
|
180181
|
+
*
|
|
180182
|
+
* \`\`\`js
|
|
180183
|
+
* const store = new ${storeName}Store()
|
|
180184
|
+
*
|
|
180185
|
+
* $: browser && store.fetch({ variables });
|
|
180186
|
+
* \`\`\`
|
|
180187
|
+
*/
|
|
180161
180188
|
constructor() {
|
|
180162
180189
|
// @ts-ignore
|
|
180163
180190
|
super({})
|
|
180164
180191
|
}
|
|
180165
180192
|
}
|
|
180166
180193
|
|
|
180167
|
-
|
|
180168
|
-
|
|
180194
|
+
/**
|
|
180195
|
+
* ### Manual Loads
|
|
180196
|
+
* Usually your load function will look like this:
|
|
180197
|
+
*
|
|
180198
|
+
* \`\`\`js
|
|
180199
|
+
* import { load_${artifactName} } from '$houdini';
|
|
180200
|
+
* import type { PageLoad } from './$types';
|
|
180201
|
+
*
|
|
180202
|
+
* export const load: PageLoad = async (event) => {
|
|
180203
|
+
* const variables = {
|
|
180204
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
180205
|
+
* };
|
|
180206
|
+
*
|
|
180207
|
+
* return await load_${artifactName}({ event, variables });
|
|
180208
|
+
* };
|
|
180209
|
+
* \`\`\`
|
|
180210
|
+
*
|
|
180211
|
+
* ### Multiple stores to load
|
|
180212
|
+
* You can trigger them in parallel with \`loadAll\` function
|
|
180213
|
+
*
|
|
180214
|
+
* \`\`\`js
|
|
180215
|
+
* import { loadAll, load_${artifactName} } from '$houdini';
|
|
180216
|
+
* import type { PageLoad } from './$types';
|
|
180217
|
+
*
|
|
180218
|
+
* export const load: PageLoad = async (event) => {
|
|
180219
|
+
* const variables = {
|
|
180220
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
180221
|
+
* };
|
|
180222
|
+
*
|
|
180223
|
+
* return await await loadAll(
|
|
180224
|
+
* load_${artifactName}({ event, variables }),
|
|
180225
|
+
* // load_ANOTHER_STORE
|
|
180226
|
+
* );
|
|
180227
|
+
* };
|
|
180228
|
+
* \`\`\`
|
|
180229
|
+
*/
|
|
180169
180230
|
export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
|
|
180170
180231
|
|
|
180232
|
+
export const ${globalStoreName}: ${storeName}
|
|
180233
|
+
|
|
180171
180234
|
export default ${storeName}
|
|
180172
180235
|
`;
|
|
180173
180236
|
await Promise.all([
|
|
@@ -181428,7 +181491,7 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
181428
181491
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
181429
181492
|
},
|
|
181430
181493
|
"adapter.js": ({ content }) => {
|
|
181431
|
-
const sveltekit_adapter = `import { browser,
|
|
181494
|
+
const sveltekit_adapter = `import { browser, building } from '$app/environment'
|
|
181432
181495
|
import { error as svelteKitError } from '@sveltejs/kit'
|
|
181433
181496
|
|
|
181434
181497
|
export const isBrowser = browser
|
|
@@ -181439,7 +181502,7 @@ export function setClientStarted() {
|
|
|
181439
181502
|
clientStarted = true
|
|
181440
181503
|
}
|
|
181441
181504
|
|
|
181442
|
-
export const isPrerender =
|
|
181505
|
+
export const isPrerender = building
|
|
181443
181506
|
|
|
181444
181507
|
export const error = svelteKitError
|
|
181445
181508
|
`;
|
|
@@ -30808,10 +30808,10 @@ var require_main5 = __commonJS({
|
|
|
30808
30808
|
}
|
|
30809
30809
|
});
|
|
30810
30810
|
|
|
30811
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30811
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js
|
|
30812
30812
|
var HttpError, Redirect, ValidationError;
|
|
30813
30813
|
var init_control = __esm({
|
|
30814
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30814
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js"() {
|
|
30815
30815
|
HttpError = class {
|
|
30816
30816
|
constructor(status, body) {
|
|
30817
30817
|
this.status = status;
|
|
@@ -30842,7 +30842,7 @@ var init_control = __esm({
|
|
|
30842
30842
|
}
|
|
30843
30843
|
});
|
|
30844
30844
|
|
|
30845
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30845
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js
|
|
30846
30846
|
var exports_exports = {};
|
|
30847
30847
|
__export(exports_exports, {
|
|
30848
30848
|
error: () => error2,
|
|
@@ -30851,10 +30851,13 @@ __export(exports_exports, {
|
|
|
30851
30851
|
redirect: () => redirect
|
|
30852
30852
|
});
|
|
30853
30853
|
function error2(status, message) {
|
|
30854
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 400 || status > 599)) {
|
|
30855
|
+
throw new Error(`HTTP error status codes must be between 400 and 599 \u2014 ${status} is invalid`);
|
|
30856
|
+
}
|
|
30854
30857
|
return new HttpError(status, message);
|
|
30855
30858
|
}
|
|
30856
30859
|
function redirect(status, location) {
|
|
30857
|
-
if (isNaN(status) || status < 300 || status > 308) {
|
|
30860
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 300 || status > 308)) {
|
|
30858
30861
|
throw new Error("Invalid status code");
|
|
30859
30862
|
}
|
|
30860
30863
|
return new Redirect(status, location);
|
|
@@ -30873,7 +30876,7 @@ function invalid(status, data2) {
|
|
|
30873
30876
|
return new ValidationError(status, data2);
|
|
30874
30877
|
}
|
|
30875
30878
|
var init_exports = __esm({
|
|
30876
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30879
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js"() {
|
|
30877
30880
|
init_control();
|
|
30878
30881
|
}
|
|
30879
30882
|
});
|
|
@@ -179954,7 +179957,7 @@ type AfterLoadData = {
|
|
|
179954
179957
|
};
|
|
179955
179958
|
|
|
179956
179959
|
export type AfterLoadEvent = {
|
|
179957
|
-
event:
|
|
179960
|
+
event: ${type}LoadEvent
|
|
179958
179961
|
data: AfterLoadData
|
|
179959
179962
|
input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
|
|
179960
179963
|
};
|
|
@@ -179968,7 +179971,7 @@ function internal_append_afterLoad(queries) {
|
|
|
179968
179971
|
}
|
|
179969
179972
|
function append_beforeLoad(beforeLoad, type) {
|
|
179970
179973
|
return beforeLoad ? `
|
|
179971
|
-
export type BeforeLoadEvent =
|
|
179974
|
+
export type BeforeLoadEvent = ${type}LoadEvent;
|
|
179972
179975
|
type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
|
|
179973
179976
|
` : "";
|
|
179974
179977
|
}
|
|
@@ -180123,8 +180126,6 @@ async function queryStore({ config: config2, plugin_root }, doc) {
|
|
|
180123
180126
|
const storeData = `${statement}
|
|
180124
180127
|
import artifact from '$houdini/artifacts/${artifactName}'
|
|
180125
180128
|
|
|
180126
|
-
// create the query store
|
|
180127
|
-
|
|
180128
180129
|
export class ${storeName} extends ${store_class} {
|
|
180129
180130
|
constructor() {
|
|
180130
180131
|
super({
|
|
@@ -180154,16 +180155,78 @@ export default ${globalStoreName}
|
|
|
180154
180155
|
const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
|
|
180155
180156
|
|
|
180156
180157
|
export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
|
|
180158
|
+
/**
|
|
180159
|
+
* ### Route Loads
|
|
180160
|
+
* In a route's load function, manually instantiating a store can be used to look at the result:
|
|
180161
|
+
*
|
|
180162
|
+
* \`\`\`js
|
|
180163
|
+
* export async function load(event) {
|
|
180164
|
+
* const store = new ${storeName}Store()
|
|
180165
|
+
* const { data } = await store.fetch({event})
|
|
180166
|
+
* console.log('do something with', data)
|
|
180167
|
+
*
|
|
180168
|
+
* return {
|
|
180169
|
+
* ${storeName}: store,
|
|
180170
|
+
* }
|
|
180171
|
+
* }
|
|
180172
|
+
*
|
|
180173
|
+
* \`\`\`
|
|
180174
|
+
*
|
|
180175
|
+
* ### Client Side Loading
|
|
180176
|
+
* When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
|
|
180177
|
+
*
|
|
180178
|
+
* \`\`\`js
|
|
180179
|
+
* const store = new ${storeName}Store()
|
|
180180
|
+
*
|
|
180181
|
+
* $: browser && store.fetch({ variables });
|
|
180182
|
+
* \`\`\`
|
|
180183
|
+
*/
|
|
180157
180184
|
constructor() {
|
|
180158
180185
|
// @ts-ignore
|
|
180159
180186
|
super({})
|
|
180160
180187
|
}
|
|
180161
180188
|
}
|
|
180162
180189
|
|
|
180163
|
-
|
|
180164
|
-
|
|
180190
|
+
/**
|
|
180191
|
+
* ### Manual Loads
|
|
180192
|
+
* Usually your load function will look like this:
|
|
180193
|
+
*
|
|
180194
|
+
* \`\`\`js
|
|
180195
|
+
* import { load_${artifactName} } from '$houdini';
|
|
180196
|
+
* import type { PageLoad } from './$types';
|
|
180197
|
+
*
|
|
180198
|
+
* export const load: PageLoad = async (event) => {
|
|
180199
|
+
* const variables = {
|
|
180200
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
180201
|
+
* };
|
|
180202
|
+
*
|
|
180203
|
+
* return await load_${artifactName}({ event, variables });
|
|
180204
|
+
* };
|
|
180205
|
+
* \`\`\`
|
|
180206
|
+
*
|
|
180207
|
+
* ### Multiple stores to load
|
|
180208
|
+
* You can trigger them in parallel with \`loadAll\` function
|
|
180209
|
+
*
|
|
180210
|
+
* \`\`\`js
|
|
180211
|
+
* import { loadAll, load_${artifactName} } from '$houdini';
|
|
180212
|
+
* import type { PageLoad } from './$types';
|
|
180213
|
+
*
|
|
180214
|
+
* export const load: PageLoad = async (event) => {
|
|
180215
|
+
* const variables = {
|
|
180216
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
180217
|
+
* };
|
|
180218
|
+
*
|
|
180219
|
+
* return await await loadAll(
|
|
180220
|
+
* load_${artifactName}({ event, variables }),
|
|
180221
|
+
* // load_ANOTHER_STORE
|
|
180222
|
+
* );
|
|
180223
|
+
* };
|
|
180224
|
+
* \`\`\`
|
|
180225
|
+
*/
|
|
180165
180226
|
export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
|
|
180166
180227
|
|
|
180228
|
+
export const ${globalStoreName}: ${storeName}
|
|
180229
|
+
|
|
180167
180230
|
export default ${storeName}
|
|
180168
180231
|
`;
|
|
180169
180232
|
await Promise.all([
|
|
@@ -181424,7 +181487,7 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
181424
181487
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
181425
181488
|
},
|
|
181426
181489
|
"adapter.js": ({ content }) => {
|
|
181427
|
-
const sveltekit_adapter = `import { browser,
|
|
181490
|
+
const sveltekit_adapter = `import { browser, building } from '$app/environment'
|
|
181428
181491
|
import { error as svelteKitError } from '@sveltejs/kit'
|
|
181429
181492
|
|
|
181430
181493
|
export const isBrowser = browser
|
|
@@ -181435,7 +181498,7 @@ export function setClientStarted() {
|
|
|
181435
181498
|
clientStarted = true
|
|
181436
181499
|
}
|
|
181437
181500
|
|
|
181438
|
-
export const isPrerender =
|
|
181501
|
+
export const isPrerender = building
|
|
181439
181502
|
|
|
181440
181503
|
export const error = svelteKitError
|
|
181441
181504
|
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
2
2
|
import { Subscriber } from 'svelte/store';
|
|
3
|
-
import {
|
|
3
|
+
import { ClientFetchParams, LoadEventFetchParams, QueryStore, QueryStoreFetchParams, RequestEventFetchParams, StoreConfig } from '../query';
|
|
4
4
|
import { CursorHandlers } from './cursor';
|
|
5
5
|
import { OffsetHandlers } from './offset';
|
|
6
6
|
import { PageInfo } from './pageInfo';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FetchContext } from '$houdini/runtime/lib/network';
|
|
2
2
|
import type { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
3
|
-
import { CachePolicy, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
|
|
4
|
-
import { SubscriptionSpec, HoudiniFetchContext } from '$houdini/runtime/lib/types';
|
|
3
|
+
import { CachePolicy, GraphQLObject, HoudiniFetchContext, QueryResult, SubscriptionSpec } from '$houdini/runtime/lib/types';
|
|
5
4
|
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
6
5
|
import { Readable, Writable } from 'svelte/store';
|
|
7
6
|
import { BaseStore } from './store';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
2
2
|
import { Subscriber } from 'svelte/store';
|
|
3
|
-
import {
|
|
3
|
+
import { ClientFetchParams, LoadEventFetchParams, QueryStore, QueryStoreFetchParams, RequestEventFetchParams, StoreConfig } from '../query';
|
|
4
4
|
import { CursorHandlers } from './cursor';
|
|
5
5
|
import { OffsetHandlers } from './offset';
|
|
6
6
|
import { PageInfo } from './pageInfo';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FetchContext } from '$houdini/runtime/lib/network';
|
|
2
2
|
import type { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
3
|
-
import { CachePolicy, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
|
|
4
|
-
import { SubscriptionSpec, HoudiniFetchContext } from '$houdini/runtime/lib/types';
|
|
3
|
+
import { CachePolicy, GraphQLObject, HoudiniFetchContext, QueryResult, SubscriptionSpec } from '$houdini/runtime/lib/types';
|
|
5
4
|
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
6
5
|
import { Readable, Writable } from 'svelte/store';
|
|
7
6
|
import { BaseStore } from './store';
|
|
@@ -34,16 +34,15 @@ var log = __toESM(require("$houdini/runtime/lib/log"), 1);
|
|
|
34
34
|
var import_network = require("$houdini/runtime/lib/network");
|
|
35
35
|
var import_scalars = require("$houdini/runtime/lib/scalars");
|
|
36
36
|
var import_types = require("$houdini/runtime/lib/types");
|
|
37
|
-
var import_types2 = require("$houdini/runtime/lib/types");
|
|
38
37
|
var import_store = require("svelte/store");
|
|
39
38
|
var import_adapter = require("../adapter");
|
|
40
|
-
var
|
|
39
|
+
var import_network2 = require("../network");
|
|
41
40
|
var import_session = require("../session");
|
|
42
41
|
var import_store2 = require("./store");
|
|
43
42
|
class QueryStore extends import_store2.BaseStore {
|
|
44
43
|
artifact;
|
|
45
44
|
variables;
|
|
46
|
-
kind =
|
|
45
|
+
kind = import_types.CompiledQueryKind;
|
|
47
46
|
store;
|
|
48
47
|
lastVariables = null;
|
|
49
48
|
subscriptionSpec = null;
|
|
@@ -83,9 +82,7 @@ class QueryStore extends import_store2.BaseStore {
|
|
|
83
82
|
}
|
|
84
83
|
if (this.loadPending && isComponentFetch) {
|
|
85
84
|
log.error(`\u26A0\uFE0F Encountered fetch from your component while ${this.storeName}.load was running.
|
|
86
|
-
This will result in duplicate queries. If you are trying to ensure there is always a good value, please a CachePolicy instead
|
|
87
|
-
If this is leftovers from old versions of houdini, you can safely remove this \`${this.storeName}\`.fetch() from your component.
|
|
88
|
-
`);
|
|
85
|
+
This will result in duplicate queries. If you are trying to ensure there is always a good value, please a CachePolicy instead.`);
|
|
89
86
|
return (0, import_store.get)(this.store);
|
|
90
87
|
}
|
|
91
88
|
if (isComponentFetch) {
|
|
@@ -94,8 +91,7 @@ If this is leftovers from old versions of houdini, you can safely remove this \`
|
|
|
94
91
|
if (isLoadFetch) {
|
|
95
92
|
this.loadPending = true;
|
|
96
93
|
}
|
|
97
|
-
const
|
|
98
|
-
const request = this.fetchAndCache({
|
|
94
|
+
const fetchArgs = {
|
|
99
95
|
config,
|
|
100
96
|
context,
|
|
101
97
|
artifact: this.artifact,
|
|
@@ -106,7 +102,22 @@ If this is leftovers from old versions of houdini, you can safely remove this \`
|
|
|
106
102
|
this.loadPending = val;
|
|
107
103
|
this.setFetching(val);
|
|
108
104
|
}
|
|
109
|
-
}
|
|
105
|
+
};
|
|
106
|
+
const fakeAwait = import_adapter.clientStarted && import_adapter.isBrowser && !params?.blocking;
|
|
107
|
+
if (policy !== import_types.CachePolicy.NetworkOnly && fakeAwait) {
|
|
108
|
+
const cachedStore = await this.fetchAndCache({
|
|
109
|
+
...fetchArgs,
|
|
110
|
+
rawCacheOnlyResult: true
|
|
111
|
+
});
|
|
112
|
+
if (cachedStore && cachedStore?.result.data) {
|
|
113
|
+
this.store.update((s) => ({
|
|
114
|
+
...s,
|
|
115
|
+
data: cachedStore?.result.data,
|
|
116
|
+
isFetching: false
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const request = this.fetchAndCache(fetchArgs);
|
|
110
121
|
if (params.then) {
|
|
111
122
|
request.then((val) => params.then?.(val.result.data));
|
|
112
123
|
}
|
|
@@ -144,19 +155,23 @@ If this is leftovers from old versions of houdini, you can safely remove this \`
|
|
|
144
155
|
ignoreFollowup,
|
|
145
156
|
setLoadPending,
|
|
146
157
|
policy,
|
|
147
|
-
context
|
|
158
|
+
context,
|
|
159
|
+
rawCacheOnlyResult = false
|
|
148
160
|
}) {
|
|
149
161
|
const request = await (0, import_network.fetchQuery)({
|
|
150
162
|
...context,
|
|
151
|
-
client: await (0,
|
|
163
|
+
client: await (0, import_network2.getCurrentClient)(),
|
|
152
164
|
setFetching: (val) => this.setFetching(val),
|
|
153
165
|
artifact,
|
|
154
166
|
variables,
|
|
155
167
|
cached,
|
|
156
|
-
policy,
|
|
168
|
+
policy: rawCacheOnlyResult ? import_types.CachePolicy.CacheOnly : policy,
|
|
157
169
|
context
|
|
158
170
|
});
|
|
159
171
|
const { result, source, partial } = request;
|
|
172
|
+
if (rawCacheOnlyResult) {
|
|
173
|
+
return request;
|
|
174
|
+
}
|
|
160
175
|
setLoadPending(false);
|
|
161
176
|
if (result.data && source !== import_types.DataSource.Cache) {
|
|
162
177
|
(0, import_runtime.getCache)().write({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
|
|
2
2
|
import { Subscriber } from 'svelte/store';
|
|
3
|
-
import {
|
|
3
|
+
import { ClientFetchParams, LoadEventFetchParams, QueryStore, QueryStoreFetchParams, RequestEventFetchParams, StoreConfig } from '../query';
|
|
4
4
|
import { CursorHandlers } from './cursor';
|
|
5
5
|
import { OffsetHandlers } from './offset';
|
|
6
6
|
import { PageInfo } from './pageInfo';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FetchContext } from '$houdini/runtime/lib/network';
|
|
2
2
|
import type { QueryArtifact } from '$houdini/runtime/lib/types';
|
|
3
|
-
import { CachePolicy, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
|
|
4
|
-
import { SubscriptionSpec, HoudiniFetchContext } from '$houdini/runtime/lib/types';
|
|
3
|
+
import { CachePolicy, GraphQLObject, HoudiniFetchContext, QueryResult, SubscriptionSpec } from '$houdini/runtime/lib/types';
|
|
5
4
|
import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
|
|
6
5
|
import { Readable, Writable } from 'svelte/store';
|
|
7
6
|
import { BaseStore } from './store';
|
|
@@ -3,12 +3,13 @@ import { deepEquals } from "$houdini/runtime/lib/deepEquals";
|
|
|
3
3
|
import * as log from "$houdini/runtime/lib/log";
|
|
4
4
|
import { fetchQuery } from "$houdini/runtime/lib/network";
|
|
5
5
|
import { marshalInputs, unmarshalSelection } from "$houdini/runtime/lib/scalars";
|
|
6
|
-
import { CachePolicy, DataSource } from "$houdini/runtime/lib/types";
|
|
7
6
|
import {
|
|
8
|
-
|
|
7
|
+
CachePolicy,
|
|
8
|
+
CompiledQueryKind,
|
|
9
|
+
DataSource
|
|
9
10
|
} from "$houdini/runtime/lib/types";
|
|
10
11
|
import { get, writable } from "svelte/store";
|
|
11
|
-
import { clientStarted,
|
|
12
|
+
import { clientStarted, error, isBrowser } from "../adapter";
|
|
12
13
|
import { getCurrentClient } from "../network";
|
|
13
14
|
import { getSession } from "../session";
|
|
14
15
|
import { BaseStore } from "./store";
|
|
@@ -55,9 +56,7 @@ class QueryStore extends BaseStore {
|
|
|
55
56
|
}
|
|
56
57
|
if (this.loadPending && isComponentFetch) {
|
|
57
58
|
log.error(`\u26A0\uFE0F Encountered fetch from your component while ${this.storeName}.load was running.
|
|
58
|
-
This will result in duplicate queries. If you are trying to ensure there is always a good value, please a CachePolicy instead
|
|
59
|
-
If this is leftovers from old versions of houdini, you can safely remove this \`${this.storeName}\`.fetch() from your component.
|
|
60
|
-
`);
|
|
59
|
+
This will result in duplicate queries. If you are trying to ensure there is always a good value, please a CachePolicy instead.`);
|
|
61
60
|
return get(this.store);
|
|
62
61
|
}
|
|
63
62
|
if (isComponentFetch) {
|
|
@@ -66,8 +65,7 @@ If this is leftovers from old versions of houdini, you can safely remove this \`
|
|
|
66
65
|
if (isLoadFetch) {
|
|
67
66
|
this.loadPending = true;
|
|
68
67
|
}
|
|
69
|
-
const
|
|
70
|
-
const request = this.fetchAndCache({
|
|
68
|
+
const fetchArgs = {
|
|
71
69
|
config,
|
|
72
70
|
context,
|
|
73
71
|
artifact: this.artifact,
|
|
@@ -78,7 +76,22 @@ If this is leftovers from old versions of houdini, you can safely remove this \`
|
|
|
78
76
|
this.loadPending = val;
|
|
79
77
|
this.setFetching(val);
|
|
80
78
|
}
|
|
81
|
-
}
|
|
79
|
+
};
|
|
80
|
+
const fakeAwait = clientStarted && isBrowser && !params?.blocking;
|
|
81
|
+
if (policy !== CachePolicy.NetworkOnly && fakeAwait) {
|
|
82
|
+
const cachedStore = await this.fetchAndCache({
|
|
83
|
+
...fetchArgs,
|
|
84
|
+
rawCacheOnlyResult: true
|
|
85
|
+
});
|
|
86
|
+
if (cachedStore && cachedStore?.result.data) {
|
|
87
|
+
this.store.update((s) => ({
|
|
88
|
+
...s,
|
|
89
|
+
data: cachedStore?.result.data,
|
|
90
|
+
isFetching: false
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const request = this.fetchAndCache(fetchArgs);
|
|
82
95
|
if (params.then) {
|
|
83
96
|
request.then((val) => params.then?.(val.result.data));
|
|
84
97
|
}
|
|
@@ -116,7 +129,8 @@ If this is leftovers from old versions of houdini, you can safely remove this \`
|
|
|
116
129
|
ignoreFollowup,
|
|
117
130
|
setLoadPending,
|
|
118
131
|
policy,
|
|
119
|
-
context
|
|
132
|
+
context,
|
|
133
|
+
rawCacheOnlyResult = false
|
|
120
134
|
}) {
|
|
121
135
|
const request = await fetchQuery({
|
|
122
136
|
...context,
|
|
@@ -125,10 +139,13 @@ If this is leftovers from old versions of houdini, you can safely remove this \`
|
|
|
125
139
|
artifact,
|
|
126
140
|
variables,
|
|
127
141
|
cached,
|
|
128
|
-
policy,
|
|
142
|
+
policy: rawCacheOnlyResult ? CachePolicy.CacheOnly : policy,
|
|
129
143
|
context
|
|
130
144
|
});
|
|
131
145
|
const { result, source, partial } = request;
|
|
146
|
+
if (rawCacheOnlyResult) {
|
|
147
|
+
return request;
|
|
148
|
+
}
|
|
132
149
|
setLoadPending(false);
|
|
133
150
|
if (result.data && source !== DataSource.Cache) {
|
|
134
151
|
getCache().write({
|
package/build/test-cjs/index.js
CHANGED
|
@@ -30803,10 +30803,10 @@ var require_main7 = __commonJS({
|
|
|
30803
30803
|
}
|
|
30804
30804
|
});
|
|
30805
30805
|
|
|
30806
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30806
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js
|
|
30807
30807
|
var HttpError, Redirect, ValidationError;
|
|
30808
30808
|
var init_control = __esm({
|
|
30809
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30809
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js"() {
|
|
30810
30810
|
HttpError = class {
|
|
30811
30811
|
constructor(status, body) {
|
|
30812
30812
|
this.status = status;
|
|
@@ -30837,7 +30837,7 @@ var init_control = __esm({
|
|
|
30837
30837
|
}
|
|
30838
30838
|
});
|
|
30839
30839
|
|
|
30840
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30840
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js
|
|
30841
30841
|
var exports_exports = {};
|
|
30842
30842
|
__export(exports_exports, {
|
|
30843
30843
|
error: () => error2,
|
|
@@ -30846,10 +30846,13 @@ __export(exports_exports, {
|
|
|
30846
30846
|
redirect: () => redirect
|
|
30847
30847
|
});
|
|
30848
30848
|
function error2(status, message) {
|
|
30849
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 400 || status > 599)) {
|
|
30850
|
+
throw new Error(`HTTP error status codes must be between 400 and 599 \u2014 ${status} is invalid`);
|
|
30851
|
+
}
|
|
30849
30852
|
return new HttpError(status, message);
|
|
30850
30853
|
}
|
|
30851
30854
|
function redirect(status, location) {
|
|
30852
|
-
if (isNaN(status) || status < 300 || status > 308) {
|
|
30855
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 300 || status > 308)) {
|
|
30853
30856
|
throw new Error("Invalid status code");
|
|
30854
30857
|
}
|
|
30855
30858
|
return new Redirect(status, location);
|
|
@@ -30868,7 +30871,7 @@ function invalid(status, data2) {
|
|
|
30868
30871
|
return new ValidationError(status, data2);
|
|
30869
30872
|
}
|
|
30870
30873
|
var init_exports = __esm({
|
|
30871
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30874
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js"() {
|
|
30872
30875
|
init_control();
|
|
30873
30876
|
}
|
|
30874
30877
|
});
|
|
@@ -294613,7 +294616,7 @@ type AfterLoadData = {
|
|
|
294613
294616
|
};
|
|
294614
294617
|
|
|
294615
294618
|
export type AfterLoadEvent = {
|
|
294616
|
-
event:
|
|
294619
|
+
event: ${type}LoadEvent
|
|
294617
294620
|
data: AfterLoadData
|
|
294618
294621
|
input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
|
|
294619
294622
|
};
|
|
@@ -294627,7 +294630,7 @@ function internal_append_afterLoad(queries) {
|
|
|
294627
294630
|
}
|
|
294628
294631
|
function append_beforeLoad(beforeLoad, type) {
|
|
294629
294632
|
return beforeLoad ? `
|
|
294630
|
-
export type BeforeLoadEvent =
|
|
294633
|
+
export type BeforeLoadEvent = ${type}LoadEvent;
|
|
294631
294634
|
type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
|
|
294632
294635
|
` : "";
|
|
294633
294636
|
}
|
|
@@ -294782,8 +294785,6 @@ async function queryStore({ config: config3, plugin_root }, doc) {
|
|
|
294782
294785
|
const storeData = `${statement}
|
|
294783
294786
|
import artifact from '$houdini/artifacts/${artifactName}'
|
|
294784
294787
|
|
|
294785
|
-
// create the query store
|
|
294786
|
-
|
|
294787
294788
|
export class ${storeName} extends ${store_class} {
|
|
294788
294789
|
constructor() {
|
|
294789
294790
|
super({
|
|
@@ -294813,16 +294814,78 @@ export default ${globalStoreName}
|
|
|
294813
294814
|
const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
|
|
294814
294815
|
|
|
294815
294816
|
export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
|
|
294817
|
+
/**
|
|
294818
|
+
* ### Route Loads
|
|
294819
|
+
* In a route's load function, manually instantiating a store can be used to look at the result:
|
|
294820
|
+
*
|
|
294821
|
+
* \`\`\`js
|
|
294822
|
+
* export async function load(event) {
|
|
294823
|
+
* const store = new ${storeName}Store()
|
|
294824
|
+
* const { data } = await store.fetch({event})
|
|
294825
|
+
* console.log('do something with', data)
|
|
294826
|
+
*
|
|
294827
|
+
* return {
|
|
294828
|
+
* ${storeName}: store,
|
|
294829
|
+
* }
|
|
294830
|
+
* }
|
|
294831
|
+
*
|
|
294832
|
+
* \`\`\`
|
|
294833
|
+
*
|
|
294834
|
+
* ### Client Side Loading
|
|
294835
|
+
* When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
|
|
294836
|
+
*
|
|
294837
|
+
* \`\`\`js
|
|
294838
|
+
* const store = new ${storeName}Store()
|
|
294839
|
+
*
|
|
294840
|
+
* $: browser && store.fetch({ variables });
|
|
294841
|
+
* \`\`\`
|
|
294842
|
+
*/
|
|
294816
294843
|
constructor() {
|
|
294817
294844
|
// @ts-ignore
|
|
294818
294845
|
super({})
|
|
294819
294846
|
}
|
|
294820
294847
|
}
|
|
294821
294848
|
|
|
294822
|
-
|
|
294823
|
-
|
|
294849
|
+
/**
|
|
294850
|
+
* ### Manual Loads
|
|
294851
|
+
* Usually your load function will look like this:
|
|
294852
|
+
*
|
|
294853
|
+
* \`\`\`js
|
|
294854
|
+
* import { load_${artifactName} } from '$houdini';
|
|
294855
|
+
* import type { PageLoad } from './$types';
|
|
294856
|
+
*
|
|
294857
|
+
* export const load: PageLoad = async (event) => {
|
|
294858
|
+
* const variables = {
|
|
294859
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
294860
|
+
* };
|
|
294861
|
+
*
|
|
294862
|
+
* return await load_${artifactName}({ event, variables });
|
|
294863
|
+
* };
|
|
294864
|
+
* \`\`\`
|
|
294865
|
+
*
|
|
294866
|
+
* ### Multiple stores to load
|
|
294867
|
+
* You can trigger them in parallel with \`loadAll\` function
|
|
294868
|
+
*
|
|
294869
|
+
* \`\`\`js
|
|
294870
|
+
* import { loadAll, load_${artifactName} } from '$houdini';
|
|
294871
|
+
* import type { PageLoad } from './$types';
|
|
294872
|
+
*
|
|
294873
|
+
* export const load: PageLoad = async (event) => {
|
|
294874
|
+
* const variables = {
|
|
294875
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
294876
|
+
* };
|
|
294877
|
+
*
|
|
294878
|
+
* return await await loadAll(
|
|
294879
|
+
* load_${artifactName}({ event, variables }),
|
|
294880
|
+
* // load_ANOTHER_STORE
|
|
294881
|
+
* );
|
|
294882
|
+
* };
|
|
294883
|
+
* \`\`\`
|
|
294884
|
+
*/
|
|
294824
294885
|
export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
|
|
294825
294886
|
|
|
294887
|
+
export const ${globalStoreName}: ${storeName}
|
|
294888
|
+
|
|
294826
294889
|
export default ${storeName}
|
|
294827
294890
|
`;
|
|
294828
294891
|
await Promise.all([
|
|
@@ -296083,7 +296146,7 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
296083
296146
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
296084
296147
|
},
|
|
296085
296148
|
"adapter.js": ({ content }) => {
|
|
296086
|
-
const sveltekit_adapter = `import { browser,
|
|
296149
|
+
const sveltekit_adapter = `import { browser, building } from '$app/environment'
|
|
296087
296150
|
import { error as svelteKitError } from '@sveltejs/kit'
|
|
296088
296151
|
|
|
296089
296152
|
export const isBrowser = browser
|
|
@@ -296094,7 +296157,7 @@ export function setClientStarted() {
|
|
|
296094
296157
|
clientStarted = true
|
|
296095
296158
|
}
|
|
296096
296159
|
|
|
296097
|
-
export const isPrerender =
|
|
296160
|
+
export const isPrerender = building
|
|
296098
296161
|
|
|
296099
296162
|
export const error = svelteKitError
|
|
296100
296163
|
`;
|
package/build/test-esm/index.js
CHANGED
|
@@ -30808,10 +30808,10 @@ var require_main7 = __commonJS({
|
|
|
30808
30808
|
}
|
|
30809
30809
|
});
|
|
30810
30810
|
|
|
30811
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30811
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js
|
|
30812
30812
|
var HttpError, Redirect, ValidationError;
|
|
30813
30813
|
var init_control = __esm({
|
|
30814
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30814
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/runtime/control.js"() {
|
|
30815
30815
|
HttpError = class {
|
|
30816
30816
|
constructor(status, body) {
|
|
30817
30817
|
this.status = status;
|
|
@@ -30842,7 +30842,7 @@ var init_control = __esm({
|
|
|
30842
30842
|
}
|
|
30843
30843
|
});
|
|
30844
30844
|
|
|
30845
|
-
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30845
|
+
// ../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js
|
|
30846
30846
|
var exports_exports = {};
|
|
30847
30847
|
__export(exports_exports, {
|
|
30848
30848
|
error: () => error2,
|
|
@@ -30851,10 +30851,13 @@ __export(exports_exports, {
|
|
|
30851
30851
|
redirect: () => redirect
|
|
30852
30852
|
});
|
|
30853
30853
|
function error2(status, message) {
|
|
30854
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 400 || status > 599)) {
|
|
30855
|
+
throw new Error(`HTTP error status codes must be between 400 and 599 \u2014 ${status} is invalid`);
|
|
30856
|
+
}
|
|
30854
30857
|
return new HttpError(status, message);
|
|
30855
30858
|
}
|
|
30856
30859
|
function redirect(status, location) {
|
|
30857
|
-
if (isNaN(status) || status < 300 || status > 308) {
|
|
30860
|
+
if ((!__SVELTEKIT_BROWSER__ || __SVELTEKIT_DEV__) && (isNaN(status) || status < 300 || status > 308)) {
|
|
30858
30861
|
throw new Error("Invalid status code");
|
|
30859
30862
|
}
|
|
30860
30863
|
return new Redirect(status, location);
|
|
@@ -30873,7 +30876,7 @@ function invalid(status, data2) {
|
|
|
30873
30876
|
return new ValidationError(status, data2);
|
|
30874
30877
|
}
|
|
30875
30878
|
var init_exports = __esm({
|
|
30876
|
-
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.
|
|
30879
|
+
"../../node_modules/.pnpm/@sveltejs+kit@1.0.0-next.561_svelte@3.52.0+vite@3.2.4/node_modules/@sveltejs/kit/src/exports/index.js"() {
|
|
30877
30880
|
init_control();
|
|
30878
30881
|
}
|
|
30879
30882
|
});
|
|
@@ -294602,7 +294605,7 @@ type AfterLoadData = {
|
|
|
294602
294605
|
};
|
|
294603
294606
|
|
|
294604
294607
|
export type AfterLoadEvent = {
|
|
294605
|
-
event:
|
|
294608
|
+
event: ${type}LoadEvent
|
|
294606
294609
|
data: AfterLoadData
|
|
294607
294610
|
input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
|
|
294608
294611
|
};
|
|
@@ -294616,7 +294619,7 @@ function internal_append_afterLoad(queries) {
|
|
|
294616
294619
|
}
|
|
294617
294620
|
function append_beforeLoad(beforeLoad, type) {
|
|
294618
294621
|
return beforeLoad ? `
|
|
294619
|
-
export type BeforeLoadEvent =
|
|
294622
|
+
export type BeforeLoadEvent = ${type}LoadEvent;
|
|
294620
294623
|
type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
|
|
294621
294624
|
` : "";
|
|
294622
294625
|
}
|
|
@@ -294771,8 +294774,6 @@ async function queryStore({ config: config3, plugin_root }, doc) {
|
|
|
294771
294774
|
const storeData = `${statement}
|
|
294772
294775
|
import artifact from '$houdini/artifacts/${artifactName}'
|
|
294773
294776
|
|
|
294774
|
-
// create the query store
|
|
294775
|
-
|
|
294776
294777
|
export class ${storeName} extends ${store_class} {
|
|
294777
294778
|
constructor() {
|
|
294778
294779
|
super({
|
|
@@ -294802,16 +294803,78 @@ export default ${globalStoreName}
|
|
|
294802
294803
|
const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
|
|
294803
294804
|
|
|
294804
294805
|
export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
|
|
294806
|
+
/**
|
|
294807
|
+
* ### Route Loads
|
|
294808
|
+
* In a route's load function, manually instantiating a store can be used to look at the result:
|
|
294809
|
+
*
|
|
294810
|
+
* \`\`\`js
|
|
294811
|
+
* export async function load(event) {
|
|
294812
|
+
* const store = new ${storeName}Store()
|
|
294813
|
+
* const { data } = await store.fetch({event})
|
|
294814
|
+
* console.log('do something with', data)
|
|
294815
|
+
*
|
|
294816
|
+
* return {
|
|
294817
|
+
* ${storeName}: store,
|
|
294818
|
+
* }
|
|
294819
|
+
* }
|
|
294820
|
+
*
|
|
294821
|
+
* \`\`\`
|
|
294822
|
+
*
|
|
294823
|
+
* ### Client Side Loading
|
|
294824
|
+
* When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
|
|
294825
|
+
*
|
|
294826
|
+
* \`\`\`js
|
|
294827
|
+
* const store = new ${storeName}Store()
|
|
294828
|
+
*
|
|
294829
|
+
* $: browser && store.fetch({ variables });
|
|
294830
|
+
* \`\`\`
|
|
294831
|
+
*/
|
|
294805
294832
|
constructor() {
|
|
294806
294833
|
// @ts-ignore
|
|
294807
294834
|
super({})
|
|
294808
294835
|
}
|
|
294809
294836
|
}
|
|
294810
294837
|
|
|
294811
|
-
|
|
294812
|
-
|
|
294838
|
+
/**
|
|
294839
|
+
* ### Manual Loads
|
|
294840
|
+
* Usually your load function will look like this:
|
|
294841
|
+
*
|
|
294842
|
+
* \`\`\`js
|
|
294843
|
+
* import { load_${artifactName} } from '$houdini';
|
|
294844
|
+
* import type { PageLoad } from './$types';
|
|
294845
|
+
*
|
|
294846
|
+
* export const load: PageLoad = async (event) => {
|
|
294847
|
+
* const variables = {
|
|
294848
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
294849
|
+
* };
|
|
294850
|
+
*
|
|
294851
|
+
* return await load_${artifactName}({ event, variables });
|
|
294852
|
+
* };
|
|
294853
|
+
* \`\`\`
|
|
294854
|
+
*
|
|
294855
|
+
* ### Multiple stores to load
|
|
294856
|
+
* You can trigger them in parallel with \`loadAll\` function
|
|
294857
|
+
*
|
|
294858
|
+
* \`\`\`js
|
|
294859
|
+
* import { loadAll, load_${artifactName} } from '$houdini';
|
|
294860
|
+
* import type { PageLoad } from './$types';
|
|
294861
|
+
*
|
|
294862
|
+
* export const load: PageLoad = async (event) => {
|
|
294863
|
+
* const variables = {
|
|
294864
|
+
* id: // Something like: event.url.searchParams.get('id')
|
|
294865
|
+
* };
|
|
294866
|
+
*
|
|
294867
|
+
* return await await loadAll(
|
|
294868
|
+
* load_${artifactName}({ event, variables }),
|
|
294869
|
+
* // load_ANOTHER_STORE
|
|
294870
|
+
* );
|
|
294871
|
+
* };
|
|
294872
|
+
* \`\`\`
|
|
294873
|
+
*/
|
|
294813
294874
|
export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
|
|
294814
294875
|
|
|
294876
|
+
export const ${globalStoreName}: ${storeName}
|
|
294877
|
+
|
|
294815
294878
|
export default ${storeName}
|
|
294816
294879
|
`;
|
|
294817
294880
|
await Promise.all([
|
|
@@ -296072,7 +296135,7 @@ var HoudiniSveltePlugin = async () => ({
|
|
|
296072
296135
|
return content.replace("HOUDINI_CLIENT_PATH", relativePath);
|
|
296073
296136
|
},
|
|
296074
296137
|
"adapter.js": ({ content }) => {
|
|
296075
|
-
const sveltekit_adapter = `import { browser,
|
|
296138
|
+
const sveltekit_adapter = `import { browser, building } from '$app/environment'
|
|
296076
296139
|
import { error as svelteKitError } from '@sveltejs/kit'
|
|
296077
296140
|
|
|
296078
296141
|
export const isBrowser = browser
|
|
@@ -296083,7 +296146,7 @@ export function setClientStarted() {
|
|
|
296083
296146
|
clientStarted = true
|
|
296084
296147
|
}
|
|
296085
296148
|
|
|
296086
|
-
export const isPrerender =
|
|
296149
|
+
export const isPrerender = building
|
|
296087
296150
|
|
|
296088
296151
|
export const error = svelteKitError
|
|
296089
296152
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-svelte",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.14",
|
|
4
4
|
"description": "The svelte plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@kitql/helper": "^0.5.0",
|
|
22
|
-
"@sveltejs/kit": "1.0.0-next.
|
|
22
|
+
"@sveltejs/kit": "1.0.0-next.561",
|
|
23
23
|
"ast-types": "^0.15.1",
|
|
24
24
|
"estree-walker": "^3.0.1",
|
|
25
25
|
"graphql": "^15.8.0",
|
|
26
|
-
"houdini": "^0.17.12",
|
|
27
26
|
"minimatch": "^5.1.0",
|
|
28
27
|
"recast": "^0.21.5",
|
|
29
|
-
"svelte": "^3.52.0"
|
|
28
|
+
"svelte": "^3.52.0",
|
|
29
|
+
"houdini": "^0.17.14"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/minimatch": "^5.1.2",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"vitest": "^0.23.4",
|
|
34
|
+
"scripts": "^1.0.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"graphql": "^14.0.0 || ^15.0.0"
|