houdini-svelte 0.17.12 → 0.17.13

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.
@@ -179958,7 +179958,7 @@ type AfterLoadData = {
179958
179958
  };
179959
179959
 
179960
179960
  export type AfterLoadEvent = {
179961
- event: PageLoadEvent
179961
+ event: ${type}LoadEvent
179962
179962
  data: AfterLoadData
179963
179963
  input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
179964
179964
  };
@@ -179972,7 +179972,7 @@ function internal_append_afterLoad(queries) {
179972
179972
  }
179973
179973
  function append_beforeLoad(beforeLoad, type) {
179974
179974
  return beforeLoad ? `
179975
- export type BeforeLoadEvent = PageLoadEvent;
179975
+ export type BeforeLoadEvent = ${type}LoadEvent;
179976
179976
  type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
179977
179977
  ` : "";
179978
179978
  }
@@ -180127,8 +180127,6 @@ async function queryStore({ config: config2, plugin_root }, doc) {
180127
180127
  const storeData = `${statement}
180128
180128
  import artifact from '$houdini/artifacts/${artifactName}'
180129
180129
 
180130
- // create the query store
180131
-
180132
180130
  export class ${storeName} extends ${store_class} {
180133
180131
  constructor() {
180134
180132
  super({
@@ -180158,16 +180156,78 @@ export default ${globalStoreName}
180158
180156
  const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
180159
180157
 
180160
180158
  export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
180159
+ /**
180160
+ * ### Route Loads
180161
+ * In a route's load function, manually instantiating a store can be used to look at the result:
180162
+ *
180163
+ * \`\`\`js
180164
+ * export async function load(event) {
180165
+ * const store = new ${storeName}Store()
180166
+ * const { data } = await store.fetch({event})
180167
+ * console.log('do something with', data)
180168
+ *
180169
+ * return {
180170
+ * ${storeName}: store,
180171
+ * }
180172
+ * }
180173
+ *
180174
+ * \`\`\`
180175
+ *
180176
+ * ### Client Side Loading
180177
+ * When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
180178
+ *
180179
+ * \`\`\`js
180180
+ * const store = new ${storeName}Store()
180181
+ *
180182
+ * $: browser && store.fetch({ variables });
180183
+ * \`\`\`
180184
+ */
180161
180185
  constructor() {
180162
180186
  // @ts-ignore
180163
180187
  super({})
180164
180188
  }
180165
180189
  }
180166
180190
 
180167
- export const ${globalStoreName}: ${storeName}
180168
-
180191
+ /**
180192
+ * ### Manual Loads
180193
+ * Usually your load function will look like this:
180194
+ *
180195
+ * \`\`\`js
180196
+ * import { load_${artifactName} } from '$houdini';
180197
+ * import type { PageLoad } from './$types';
180198
+ *
180199
+ * export const load: PageLoad = async (event) => {
180200
+ * const variables = {
180201
+ * id: // Something like: event.url.searchParams.get('id')
180202
+ * };
180203
+ *
180204
+ * return await load_${artifactName}({ event, variables });
180205
+ * };
180206
+ * \`\`\`
180207
+ *
180208
+ * ### Multiple stores to load
180209
+ * You can trigger them in parallel with \`loadAll\` function
180210
+ *
180211
+ * \`\`\`js
180212
+ * import { loadAll, load_${artifactName} } from '$houdini';
180213
+ * import type { PageLoad } from './$types';
180214
+ *
180215
+ * export const load: PageLoad = async (event) => {
180216
+ * const variables = {
180217
+ * id: // Something like: event.url.searchParams.get('id')
180218
+ * };
180219
+ *
180220
+ * return await await loadAll(
180221
+ * load_${artifactName}({ event, variables }),
180222
+ * // load_ANOTHER_STORE
180223
+ * );
180224
+ * };
180225
+ * \`\`\`
180226
+ */
180169
180227
  export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
180170
180228
 
180229
+ export const ${globalStoreName}: ${storeName}
180230
+
180171
180231
  export default ${storeName}
180172
180232
  `;
180173
180233
  await Promise.all([
@@ -179954,7 +179954,7 @@ type AfterLoadData = {
179954
179954
  };
179955
179955
 
179956
179956
  export type AfterLoadEvent = {
179957
- event: PageLoadEvent
179957
+ event: ${type}LoadEvent
179958
179958
  data: AfterLoadData
179959
179959
  input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
179960
179960
  };
@@ -179968,7 +179968,7 @@ function internal_append_afterLoad(queries) {
179968
179968
  }
179969
179969
  function append_beforeLoad(beforeLoad, type) {
179970
179970
  return beforeLoad ? `
179971
- export type BeforeLoadEvent = PageLoadEvent;
179971
+ export type BeforeLoadEvent = ${type}LoadEvent;
179972
179972
  type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
179973
179973
  ` : "";
179974
179974
  }
@@ -180123,8 +180123,6 @@ async function queryStore({ config: config2, plugin_root }, doc) {
180123
180123
  const storeData = `${statement}
180124
180124
  import artifact from '$houdini/artifacts/${artifactName}'
180125
180125
 
180126
- // create the query store
180127
-
180128
180126
  export class ${storeName} extends ${store_class} {
180129
180127
  constructor() {
180130
180128
  super({
@@ -180154,16 +180152,78 @@ export default ${globalStoreName}
180154
180152
  const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
180155
180153
 
180156
180154
  export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
180155
+ /**
180156
+ * ### Route Loads
180157
+ * In a route's load function, manually instantiating a store can be used to look at the result:
180158
+ *
180159
+ * \`\`\`js
180160
+ * export async function load(event) {
180161
+ * const store = new ${storeName}Store()
180162
+ * const { data } = await store.fetch({event})
180163
+ * console.log('do something with', data)
180164
+ *
180165
+ * return {
180166
+ * ${storeName}: store,
180167
+ * }
180168
+ * }
180169
+ *
180170
+ * \`\`\`
180171
+ *
180172
+ * ### Client Side Loading
180173
+ * When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
180174
+ *
180175
+ * \`\`\`js
180176
+ * const store = new ${storeName}Store()
180177
+ *
180178
+ * $: browser && store.fetch({ variables });
180179
+ * \`\`\`
180180
+ */
180157
180181
  constructor() {
180158
180182
  // @ts-ignore
180159
180183
  super({})
180160
180184
  }
180161
180185
  }
180162
180186
 
180163
- export const ${globalStoreName}: ${storeName}
180164
-
180187
+ /**
180188
+ * ### Manual Loads
180189
+ * Usually your load function will look like this:
180190
+ *
180191
+ * \`\`\`js
180192
+ * import { load_${artifactName} } from '$houdini';
180193
+ * import type { PageLoad } from './$types';
180194
+ *
180195
+ * export const load: PageLoad = async (event) => {
180196
+ * const variables = {
180197
+ * id: // Something like: event.url.searchParams.get('id')
180198
+ * };
180199
+ *
180200
+ * return await load_${artifactName}({ event, variables });
180201
+ * };
180202
+ * \`\`\`
180203
+ *
180204
+ * ### Multiple stores to load
180205
+ * You can trigger them in parallel with \`loadAll\` function
180206
+ *
180207
+ * \`\`\`js
180208
+ * import { loadAll, load_${artifactName} } from '$houdini';
180209
+ * import type { PageLoad } from './$types';
180210
+ *
180211
+ * export const load: PageLoad = async (event) => {
180212
+ * const variables = {
180213
+ * id: // Something like: event.url.searchParams.get('id')
180214
+ * };
180215
+ *
180216
+ * return await await loadAll(
180217
+ * load_${artifactName}({ event, variables }),
180218
+ * // load_ANOTHER_STORE
180219
+ * );
180220
+ * };
180221
+ * \`\`\`
180222
+ */
180165
180223
  export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
180166
180224
 
180225
+ export const ${globalStoreName}: ${storeName}
180226
+
180167
180227
  export default ${storeName}
180168
180228
  `;
180169
180229
  await Promise.all([
@@ -1,6 +1,6 @@
1
1
  import { GraphQLObject, QueryArtifact, QueryResult } from '$houdini/runtime/lib/types';
2
2
  import { Subscriber } from 'svelte/store';
3
- import { QueryStore, StoreConfig, LoadEventFetchParams, RequestEventFetchParams, QueryStoreFetchParams, ClientFetchParams } from '../query';
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 { QueryStore, StoreConfig, LoadEventFetchParams, RequestEventFetchParams, QueryStoreFetchParams, ClientFetchParams } from '../query';
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 import_network3 = require("../network");
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 = import_types2.CompiledQueryKind;
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 fakeAwait = import_adapter.clientStarted && import_adapter.isBrowser && !params?.blocking;
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, import_network3.getCurrentClient)(),
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 { QueryStore, StoreConfig, LoadEventFetchParams, RequestEventFetchParams, QueryStoreFetchParams, ClientFetchParams } from '../query';
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
- CompiledQueryKind
7
+ CachePolicy,
8
+ CompiledQueryKind,
9
+ DataSource
9
10
  } from "$houdini/runtime/lib/types";
10
11
  import { get, writable } from "svelte/store";
11
- import { clientStarted, isBrowser, error } from "../adapter";
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 fakeAwait = clientStarted && isBrowser && !params?.blocking;
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({
@@ -294613,7 +294613,7 @@ type AfterLoadData = {
294613
294613
  };
294614
294614
 
294615
294615
  export type AfterLoadEvent = {
294616
- event: PageLoadEvent
294616
+ event: ${type}LoadEvent
294617
294617
  data: AfterLoadData
294618
294618
  input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
294619
294619
  };
@@ -294627,7 +294627,7 @@ function internal_append_afterLoad(queries) {
294627
294627
  }
294628
294628
  function append_beforeLoad(beforeLoad, type) {
294629
294629
  return beforeLoad ? `
294630
- export type BeforeLoadEvent = PageLoadEvent;
294630
+ export type BeforeLoadEvent = ${type}LoadEvent;
294631
294631
  type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
294632
294632
  ` : "";
294633
294633
  }
@@ -294782,8 +294782,6 @@ async function queryStore({ config: config3, plugin_root }, doc) {
294782
294782
  const storeData = `${statement}
294783
294783
  import artifact from '$houdini/artifacts/${artifactName}'
294784
294784
 
294785
- // create the query store
294786
-
294787
294785
  export class ${storeName} extends ${store_class} {
294788
294786
  constructor() {
294789
294787
  super({
@@ -294813,16 +294811,78 @@ export default ${globalStoreName}
294813
294811
  const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
294814
294812
 
294815
294813
  export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
294814
+ /**
294815
+ * ### Route Loads
294816
+ * In a route's load function, manually instantiating a store can be used to look at the result:
294817
+ *
294818
+ * \`\`\`js
294819
+ * export async function load(event) {
294820
+ * const store = new ${storeName}Store()
294821
+ * const { data } = await store.fetch({event})
294822
+ * console.log('do something with', data)
294823
+ *
294824
+ * return {
294825
+ * ${storeName}: store,
294826
+ * }
294827
+ * }
294828
+ *
294829
+ * \`\`\`
294830
+ *
294831
+ * ### Client Side Loading
294832
+ * When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
294833
+ *
294834
+ * \`\`\`js
294835
+ * const store = new ${storeName}Store()
294836
+ *
294837
+ * $: browser && store.fetch({ variables });
294838
+ * \`\`\`
294839
+ */
294816
294840
  constructor() {
294817
294841
  // @ts-ignore
294818
294842
  super({})
294819
294843
  }
294820
294844
  }
294821
294845
 
294822
- export const ${globalStoreName}: ${storeName}
294823
-
294846
+ /**
294847
+ * ### Manual Loads
294848
+ * Usually your load function will look like this:
294849
+ *
294850
+ * \`\`\`js
294851
+ * import { load_${artifactName} } from '$houdini';
294852
+ * import type { PageLoad } from './$types';
294853
+ *
294854
+ * export const load: PageLoad = async (event) => {
294855
+ * const variables = {
294856
+ * id: // Something like: event.url.searchParams.get('id')
294857
+ * };
294858
+ *
294859
+ * return await load_${artifactName}({ event, variables });
294860
+ * };
294861
+ * \`\`\`
294862
+ *
294863
+ * ### Multiple stores to load
294864
+ * You can trigger them in parallel with \`loadAll\` function
294865
+ *
294866
+ * \`\`\`js
294867
+ * import { loadAll, load_${artifactName} } from '$houdini';
294868
+ * import type { PageLoad } from './$types';
294869
+ *
294870
+ * export const load: PageLoad = async (event) => {
294871
+ * const variables = {
294872
+ * id: // Something like: event.url.searchParams.get('id')
294873
+ * };
294874
+ *
294875
+ * return await await loadAll(
294876
+ * load_${artifactName}({ event, variables }),
294877
+ * // load_ANOTHER_STORE
294878
+ * );
294879
+ * };
294880
+ * \`\`\`
294881
+ */
294824
294882
  export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
294825
294883
 
294884
+ export const ${globalStoreName}: ${storeName}
294885
+
294826
294886
  export default ${storeName}
294827
294887
  `;
294828
294888
  await Promise.all([
@@ -294602,7 +294602,7 @@ type AfterLoadData = {
294602
294602
  };
294603
294603
 
294604
294604
  export type AfterLoadEvent = {
294605
- event: PageLoadEvent
294605
+ event: ${type}LoadEvent
294606
294606
  data: AfterLoadData
294607
294607
  input: ${queries.filter((q) => q.variableDefinitions?.length).length ? "LoadInput" : "{}"}
294608
294608
  };
@@ -294616,7 +294616,7 @@ function internal_append_afterLoad(queries) {
294616
294616
  }
294617
294617
  function append_beforeLoad(beforeLoad, type) {
294618
294618
  return beforeLoad ? `
294619
- export type BeforeLoadEvent = PageLoadEvent;
294619
+ export type BeforeLoadEvent = ${type}LoadEvent;
294620
294620
  type BeforeLoadReturn = Awaited<ReturnType<typeof import('./+${type.toLowerCase()}').beforeLoad>>;
294621
294621
  ` : "";
294622
294622
  }
@@ -294771,8 +294771,6 @@ async function queryStore({ config: config3, plugin_root }, doc) {
294771
294771
  const storeData = `${statement}
294772
294772
  import artifact from '$houdini/artifacts/${artifactName}'
294773
294773
 
294774
- // create the query store
294775
-
294776
294774
  export class ${storeName} extends ${store_class} {
294777
294775
  constructor() {
294778
294776
  super({
@@ -294802,16 +294800,78 @@ export default ${globalStoreName}
294802
294800
  const typeDefs = `import type { ${_input}, ${_data}, ${store_class}, QueryStoreFetchParams} from '$houdini'
294803
294801
 
294804
294802
  export declare class ${storeName} extends ${store_class}<${_data}, ${_input}> {
294803
+ /**
294804
+ * ### Route Loads
294805
+ * In a route's load function, manually instantiating a store can be used to look at the result:
294806
+ *
294807
+ * \`\`\`js
294808
+ * export async function load(event) {
294809
+ * const store = new ${storeName}Store()
294810
+ * const { data } = await store.fetch({event})
294811
+ * console.log('do something with', data)
294812
+ *
294813
+ * return {
294814
+ * ${storeName}: store,
294815
+ * }
294816
+ * }
294817
+ *
294818
+ * \`\`\`
294819
+ *
294820
+ * ### Client Side Loading
294821
+ * When performing a client-side only fetch, the best practice to use a store _manually_ is to do the following:
294822
+ *
294823
+ * \`\`\`js
294824
+ * const store = new ${storeName}Store()
294825
+ *
294826
+ * $: browser && store.fetch({ variables });
294827
+ * \`\`\`
294828
+ */
294805
294829
  constructor() {
294806
294830
  // @ts-ignore
294807
294831
  super({})
294808
294832
  }
294809
294833
  }
294810
294834
 
294811
- export const ${globalStoreName}: ${storeName}
294812
-
294835
+ /**
294836
+ * ### Manual Loads
294837
+ * Usually your load function will look like this:
294838
+ *
294839
+ * \`\`\`js
294840
+ * import { load_${artifactName} } from '$houdini';
294841
+ * import type { PageLoad } from './$types';
294842
+ *
294843
+ * export const load: PageLoad = async (event) => {
294844
+ * const variables = {
294845
+ * id: // Something like: event.url.searchParams.get('id')
294846
+ * };
294847
+ *
294848
+ * return await load_${artifactName}({ event, variables });
294849
+ * };
294850
+ * \`\`\`
294851
+ *
294852
+ * ### Multiple stores to load
294853
+ * You can trigger them in parallel with \`loadAll\` function
294854
+ *
294855
+ * \`\`\`js
294856
+ * import { loadAll, load_${artifactName} } from '$houdini';
294857
+ * import type { PageLoad } from './$types';
294858
+ *
294859
+ * export const load: PageLoad = async (event) => {
294860
+ * const variables = {
294861
+ * id: // Something like: event.url.searchParams.get('id')
294862
+ * };
294863
+ *
294864
+ * return await await loadAll(
294865
+ * load_${artifactName}({ event, variables }),
294866
+ * // load_ANOTHER_STORE
294867
+ * );
294868
+ * };
294869
+ * \`\`\`
294870
+ */
294813
294871
  export declare const load_${artifactName}: (params: QueryStoreFetchParams<${_data}, ${_input}>) => Promise<{${artifactName}: ${storeName}}>
294814
294872
 
294873
+ export const ${globalStoreName}: ${storeName}
294874
+
294815
294875
  export default ${storeName}
294816
294876
  `;
294817
294877
  await Promise.all([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "0.17.12",
3
+ "version": "0.17.13",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -23,15 +23,15 @@
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.13"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/minimatch": "^5.1.2",
33
- "scripts": "^1.0.0",
34
- "vitest": "^0.23.4"
33
+ "vitest": "^0.23.4",
34
+ "scripts": "^1.0.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "graphql": "^14.0.0 || ^15.0.0"