From 7e2977ff5f1e737aebbb606e473708036f303d02 Mon Sep 17 00:00:00 2001 From: Alec Aivazis Date: Sat, 21 Jan 2023 01:36:53 -0800 Subject: [PATCH] HoudiniClient Plugins (#834) * create e2e project * init houdini * use env var for token * update lock * update * accept liveQuery handler as 3rd argument for now * clean up deprecation warnings * persist live flag in artifact * add live to artifact type * add liveQuery to store * close EventSource when unsubscribing * liveQueryHandler takes an updater instead of just returning a raw value * use third party apply_patch for grafbase test * pass session to LiveQueryHandler * remove logs * handle errors * start document observer * failing test and start store implementation * fixed all tests except lists * all tests pass * map subs to spec in one place * update snapshots * remove live from artifact * another failing test * first pass at middleware iterator * remove unused import * temporary names for phases * fix error when invoking first terminate * tweak docs * exception handling * cleanup phase * tweak * move client logic to special directory * add skeleton for rest of middlewares * fetch gives full payload * rename file * rename document observer stages ; track loading state * naming tweaks * naming and comments * plugins can specify client plugins * passing null to client_plugins prevents function invocation * accept url and fetchParams functions * users can't provide plugins and pipelines together * rework fetch plugin * start implementating plugins * implement input and mutation plugin ; fix fetching state tracking * update tests * random tidyness * failing test * query plugin includes last used variables in outbound requests * update variables before subscribing in query * move variable tracking into document observer * marshalVariables and variablesChanged from handlers * can check if variables changed right after assigning it * mutation clears layer if there is a network error * quietErrors happens at the network level now * first pass at subscriptions * typos * tests pass * tidy up type names * strengthen test * clean up typedefs * improved idempotency * rename plugin.error to plugin.throw * query plugin uses marshaled variables * start implementation query store * implement query, subscription, and mutation * query pagination * unused imports * make import logic synchronous * everything builds!! * fix import tests * move injected plugins into plugins directory * use getCurrentClient in houdini-react * fix imports * subscribe on the way out * better hook wrapping * update snapshot * test cache policy * add loading state checks to tests * dont specify pipeline on client * remove App.Sessions * query pagination works! * fix component queries * more tests passing * fix fragment cursor pagination * fragment offset and metadata tests * mutation initial state * more tests * fixed more tests * remove logging * :zap: UPDATE: App Metadata & Session * :rocket: UPDATE: libReporter config * update snapshots * move client retrieval into houdini-svelte * plugin client_plugins can be specified as a function of config file and plugin config * add throwOnError config * can update store state from handle * setup test * flatten client plugin hook names * update init and release notes * update documentPlugin wrapper for new keywords * update release notes and subscription setup * remove index from doc frontmatter * add doc page for client * flesh out client docs more * @manual_load directive & fetching default. (#831) * :sparkles: NEW: info in artifact * :sparkles: NEW: default init value * :bug: FIX: the test to be coherent! * :pencil2: UPDATE: changeset * :bug: FIX: lint * :zap: IMPROVE: serializeValue to have keys quoted * :sparkles: NEW: artifact.pluginsData * :construction: UPDATE: all artifacts + check 1 test + docs to doc * :bug: FIX: defautl default is false * :ok_hand: FIX: lint * :children_crossing: UPDATE: having the right default for core and the right tests for core * :bulb: IMPROVE: with libReporter (to comment if any config change) * :ok_hand: FIX: lint * :ok_hand: FIX: linting * start on client plugin section * flesh out plugin overview * start on your first plugin * add second plugin example * add type definition to plugin docs * add enter and exit phase sections * more doc updates * pull out data sources section * reorder subsections * add beforeNetwork phase * tweak sizing and spacing of diagram * note change of quietQueryErrors in release notes * add $houdini/plugins export * add section on Choosing a Phase * update example * subscription handler is now a function of the ClientPlugin context * add changeset * remove unused import * linter * more type imports * make sure that the plugin root directory exists * fix graphql return type generator * enter prerelease mode * start from 1.0.0-next.1 to cover last mistake * :art: UPDATE: zoomable component (first use: Workflow) * :pencil2: FIX: link & mini typo * :art: IMPROVE: colors * feedback * remove grafbase e2e test * move pipeline config to deep dive * comment tweak * grammar * add links to source of truth for typedefs * start on fetchParams specifying body * fetchParams can specify body * update automatic persisted queries * better comments * document App.Stuff * tweak comment * detect spread values * rename file * remove unused config value * add fragments to home page * remove test * rename DocumentObserver to DocumentStore * better subscription auth logic * client-plugin review * add typedefs for throwOnError and fetchParams * tweak words * punctuation * fix build errors * start single step document store * forgot to commit something * fix document store * add test for error throw * remove log * consolidate error handling * update docs * remove log * fix build errors * choosing a phase after enter vs exit * wether -> whether * punctuation * small tweaks * more tweaks * add caption * one word Co-authored-by: jycouet --- .changeset/beige-cheetahs-provide.md | 6 + .changeset/clean-rules-itch.md | 5 + .eslintrc.cjs | 7 + e2e/sveltekit/src/client.ts | 60 +- e2e/sveltekit/src/lib/QueryComponent.svelte | 2 +- e2e/sveltekit/src/routes/fetching/spec.ts | 3 +- .../pagination/fragment/offset/+page.svelte | 2 +- .../src/routes/stores/metadata/spec.ts | 6 +- .../src/routes/stores/mutation/spec.ts | 5 +- .../routes/stores/prefetch-[userId]/spec.ts | 2 +- e2e/sveltekit/vite.config.js | 17 +- example/src/client.ts | 40 +- houdini.d.ts | 2 + packages/_scripts/build.js | 2 +- .../src/plugin/codegen/index.ts | 3 +- .../src/plugin/codegen/stores/fragment.ts | 3 +- .../src/plugin/codegen/stores/index.ts | 3 +- .../src/plugin/codegen/stores/mutation.ts | 3 +- .../src/plugin/codegen/stores/query.ts | 3 +- .../src/plugin/codegen/stores/subscription.ts | 3 +- .../src/plugin/index.ts | 3 +- .../src/plugin/kit.ts | 5 +- .../src/test/index.ts | 2 +- packages/houdini-react/src/plugin/config.ts | 4 +- packages/houdini-react/src/plugin/extract.ts | 2 +- packages/houdini-react/src/plugin/index.ts | 27 +- packages/houdini-react/src/runtime/client.ts | 6 - packages/houdini-react/src/runtime/index.ts | 23 +- .../houdini-svelte/src/plugin/artifactData.ts | 28 + .../src/plugin/codegen/components/index.ts | 5 +- .../plugin/codegen/fragmentTypedefs/index.ts | 7 +- .../src/plugin/codegen/index.ts | 3 +- .../src/plugin/codegen/routes/index.ts | 16 +- .../src/plugin/codegen/stores/custom.ts | 2 +- .../plugin/codegen/stores/fragment.test.ts | 3 +- .../src/plugin/codegen/stores/fragment.ts | 5 +- .../src/plugin/codegen/stores/index.ts | 3 +- .../plugin/codegen/stores/mutation.test.ts | 3 +- .../src/plugin/codegen/stores/mutation.ts | 3 +- .../src/plugin/codegen/stores/query.test.ts | 3 +- .../src/plugin/codegen/stores/query.ts | 5 +- .../codegen/stores/subscription.test.ts | 3 +- .../src/plugin/codegen/stores/subscription.ts | 3 +- packages/houdini-svelte/src/plugin/extract.ts | 3 +- .../src/plugin/extractLoadFunction.ts | 8 +- packages/houdini-svelte/src/plugin/fsPatch.ts | 8 +- packages/houdini-svelte/src/plugin/index.ts | 48 +- packages/houdini-svelte/src/plugin/kit.ts | 10 +- .../plugin/transforms/componentQuery.test.ts | 70 +- .../src/plugin/transforms/componentQuery.ts | 152 +- .../src/plugin/transforms/index.ts | 9 +- .../src/plugin/transforms/kit/index.ts | 4 +- .../src/plugin/transforms/kit/init.ts | 2 +- .../src/plugin/transforms/kit/load.test.ts | 74 +- .../src/plugin/transforms/kit/load.ts | 62 +- .../src/plugin/transforms/kit/session.ts | 2 +- .../src/plugin/transforms/reactive.ts | 4 +- .../src/plugin/transforms/tags.ts | 5 +- .../src/plugin/transforms/types.ts | 6 +- .../src/plugin/validate.test.ts | 2 +- .../houdini-svelte/src/plugin/validate.ts | 3 +- .../houdini-svelte/src/preprocess/index.ts | 5 +- packages/houdini-svelte/src/runtime/client.ts | 5 + .../houdini-svelte/src/runtime/fragments.ts | 30 +- .../src/runtime/imports/client.ts | 5 + .../houdini-svelte/src/runtime/network.ts | 6 - .../houdini-svelte/src/runtime/session.ts | 7 +- .../src/runtime/stores/fragment.ts | 25 +- .../src/runtime/stores/mutation.ts | 166 +- .../src/runtime/stores/pagination/cursor.ts | 105 +- .../src/runtime/stores/pagination/fetch.ts | 4 +- .../src/runtime/stores/pagination/fragment.ts | 151 +- .../src/runtime/stores/pagination/offset.ts | 86 +- .../src/runtime/stores/pagination/pageInfo.ts | 2 +- .../src/runtime/stores/pagination/query.ts | 81 +- .../src/runtime/stores/query.ts | 362 +-- .../src/runtime/stores/store.ts | 13 - .../src/runtime/stores/subscription.ts | 101 +- packages/houdini-svelte/src/runtime/types.ts | 2 +- packages/houdini-svelte/src/test/index.ts | 6 +- packages/houdini/src/cmd/generate.ts | 10 +- packages/houdini/src/cmd/index.ts | 3 +- packages/houdini/src/cmd/init.ts | 41 +- .../generators/artifacts/artifacts.test.ts | 2834 +++++++++-------- .../codegen/generators/artifacts/fieldKey.ts | 2 +- .../src/codegen/generators/artifacts/index.ts | 32 +- .../codegen/generators/artifacts/indexFile.ts | 3 +- .../codegen/generators/artifacts/inputs.ts | 4 +- .../generators/artifacts/operations.ts | 5 +- .../generators/artifacts/pagination.test.ts | 644 ++-- .../generators/artifacts/policy.test.ts | 224 +- .../codegen/generators/artifacts/selection.ts | 3 +- .../src/codegen/generators/artifacts/utils.ts | 5 +- .../generators/definitions/enums.test.ts | 3 +- .../codegen/generators/definitions/enums.ts | 3 +- .../codegen/generators/definitions/index.ts | 3 +- .../generators/definitions/schema.test.ts | 3 +- .../src/codegen/generators/indexFile/index.ts | 5 +- .../generators/indexFile/indexFile.test.ts | 4 +- .../generators/persistedQueries/index.ts | 3 +- .../persistedQueries/persistedQuery.test.ts | 3 +- .../generators/runtime/graphqlFunction.ts | 91 + .../codegen/generators/runtime/index.test.ts | 74 - .../src/codegen/generators/runtime/index.ts | 131 +- .../generators/runtime/injectPlugins.test.ts | 161 + .../generators/runtime/injectPlugins.ts | 44 + .../generators/runtime/pluginIndex.test.ts | 52 + .../codegen/generators/runtime/pluginIndex.ts | 24 + .../generators/runtime/runtime.test.ts | 83 +- .../typescript/addReferencedInputTypes.ts | 3 +- .../generators/typescript/imperativeCache.ts | 5 +- .../codegen/generators/typescript/index.ts | 5 +- .../generators/typescript/inlineType.ts | 3 +- .../generators/typescript/typeReference.ts | 3 +- .../codegen/generators/typescript/types.ts | 2 +- packages/houdini/src/codegen/index.ts | 21 +- .../houdini/src/codegen/transforms/addID.ts | 3 +- .../codegen/transforms/composeQueries.test.ts | 2 +- .../src/codegen/transforms/composeQueries.ts | 6 +- .../transforms/fragmentVariables.test.ts | 280 +- .../codegen/transforms/fragmentVariables.ts | 6 +- .../houdini/src/codegen/transforms/list.ts | 11 +- .../src/codegen/transforms/paginate.test.ts | 610 ++-- .../src/codegen/transforms/paginate.ts | 10 +- .../houdini/src/codegen/transforms/schema.ts | 3 +- .../src/codegen/transforms/typename.ts | 3 +- .../houdini/src/codegen/utils/commonjs.ts | 10 +- .../src/codegen/utils/flattenSelections.ts | 5 +- .../houdini/src/codegen/utils/moduleExport.ts | 2 +- .../objectIdentificationSelection.test.ts | 2 +- .../utils/objectIdentificationSelection.ts | 2 +- .../src/codegen/validators/noIDAlias.test.ts | 2 +- .../src/codegen/validators/noIDAlias.ts | 3 +- .../src/codegen/validators/typeCheck.test.ts | 4 +- .../src/codegen/validators/typeCheck.ts | 5 +- .../codegen/validators/uniqueNames.test.ts | 2 +- packages/houdini/src/lib/config.test.ts | 3 +- packages/houdini/src/lib/config.ts | 48 +- packages/houdini/src/lib/fs.ts | 4 +- packages/houdini/src/lib/graphql.ts | 2 +- packages/houdini/src/lib/imports.ts | 2 +- packages/houdini/src/lib/types.ts | 6 +- packages/houdini/src/lib/walk.ts | 9 +- packages/houdini/src/runtime/cache/cache.ts | 41 +- packages/houdini/src/runtime/cache/gc.ts | 2 +- packages/houdini/src/runtime/cache/lists.ts | 14 +- packages/houdini/src/runtime/cache/schema.ts | 5 +- packages/houdini/src/runtime/cache/stuff.ts | 4 +- .../houdini/src/runtime/cache/subscription.ts | 221 +- .../src/runtime/cache/tests/list.test.ts | 3 +- .../src/runtime/cache/tests/scalars.test.ts | 3 +- .../runtime/cache/tests/subscriptions.test.ts | 140 +- .../src/runtime/client/documentStore.test.ts | 1142 +++++++ .../src/runtime/client/documentStore.ts | 604 ++++ packages/houdini/src/runtime/client/index.ts | 90 + .../src/runtime/client/plugins/cache.test.ts | 235 ++ .../src/runtime/client/plugins/cache.ts | 116 + .../plugins/fetch.ts} | 177 +- .../src/runtime/client/plugins/fetchParams.ts | 29 + .../src/runtime/client/plugins/index.ts | 7 + .../runtime/client/plugins/injectedPlugins.ts | 8 + .../src/runtime/client/plugins/mutation.ts | 91 + .../src/runtime/client/plugins/query.ts | 72 + .../runtime/client/plugins/subscription.ts | 112 + .../runtime/client/plugins/throwOnError.ts | 39 + .../runtime/client/utils/documentPlugins.ts | 48 + .../houdini/src/runtime/client/utils/index.ts | 1 + .../houdini/src/runtime/imports/config.ts | 3 + packages/houdini/src/runtime/index.ts | 3 +- packages/houdini/src/runtime/lib/config.ts | 14 +- packages/houdini/src/runtime/lib/errors.ts | 8 - packages/houdini/src/runtime/lib/index.ts | 3 +- packages/houdini/src/runtime/lib/network.ts | 308 -- .../houdini/src/runtime/lib/scalars.test.ts | 61 +- packages/houdini/src/runtime/lib/scalars.ts | 66 +- packages/houdini/src/runtime/lib/selection.ts | 2 +- packages/houdini/src/runtime/lib/store.ts | 92 + packages/houdini/src/runtime/lib/types.ts | 31 +- packages/houdini/src/runtime/public/cache.ts | 5 +- packages/houdini/src/runtime/public/list.ts | 11 +- packages/houdini/src/runtime/public/record.ts | 8 +- .../src/runtime/public/tests/list.test.ts | 2 +- .../src/runtime/public/tests/record.test.ts | 2 +- .../houdini/src/runtime/public/tests/test.ts | 2 +- packages/houdini/src/test/index.ts | 12 +- packages/houdini/src/vite/ast.ts | 2 +- packages/houdini/src/vite/houdini.ts | 3 +- packages/houdini/src/vite/imports.ts | 6 +- packages/houdini/src/vite/index.ts | 3 +- packages/houdini/src/vite/schema.ts | 3 +- pnpm-lock.yaml | 433 ++- site/src/components/DeepDive.svelte | 3 +- site/src/components/Emoji.svelte | 3 +- site/src/components/Toolbar.svelte | 4 + site/src/components/Zoomable.svelte | 115 + site/src/components/clickOutside.js | 16 + site/src/components/index.js | 1 + site/src/layouts/_page.svelte | 14 +- site/src/lib/loadOutline.js | 83 +- site/src/routes/+page.svelte | 1 + site/src/routes/api/cache/+page.svx | 65 +- site/src/routes/api/cli/+page.svx | 1 - site/src/routes/api/client-plugins/+page.svx | 405 +++ .../routes/api/client-plugins/Authoring.svx | 114 + .../routes/api/client-plugins/Workflow.svelte | 760 +++++ site/src/routes/api/client/+page.svx | 204 ++ site/src/routes/api/config/+page.svx | 7 +- site/src/routes/api/fragments/+page.svx | 1 - site/src/routes/api/graphql/+page.svx | 1 - site/src/routes/api/index.json | 17 + site/src/routes/api/mutation/+page.svx | 1 - site/src/routes/api/query/+page.svx | 1 - site/src/routes/api/subscription/+page.svx | 173 +- site/src/routes/api/vite/+page.svx | 3 +- site/src/routes/api/welcome/+page.svx | 61 +- .../routes/guides/authentication/+page.svx | 2 - site/src/routes/guides/caching-data/+page.svx | 18 +- site/src/routes/guides/contributing/+page.svx | 15 +- site/src/routes/guides/faq/+page.svx | 1 - site/src/routes/guides/index.json | 17 + site/src/routes/guides/pagination/+page.svx | 1 - .../routes/guides/persisted-queries/+page.svx | 155 +- site/src/routes/guides/plugins/+page.svx | 2 - .../src/routes/guides/release-notes/+page.svx | 196 +- .../guides/setting-up-your-project/+page.svx | 2 +- site/src/routes/guides/typescript/+page.svx | 46 +- .../routes/guides/uploading-files/+page.svx | 1 - .../guides/working-with-graphql/+page.svx | 2 - site/src/routes/intro/fetching-data/+page.svx | 1 - site/src/routes/intro/fragments/+page.svx | 5 +- site/src/routes/intro/index.json | 4 + site/src/routes/intro/mutations/+page.svx | 1 - site/src/routes/intro/pagination/+page.svx | 115 +- site/src/routes/intro/welcome/+page.svx | 1 - site/static/images/emojis/fear.png | Bin 0 -> 5707 bytes site/static/images/emojis/scream.png | Bin 0 -> 7998 bytes site/static/styles/md.css | 18 +- 237 files changed, 9813 insertions(+), 4690 deletions(-) create mode 100644 .changeset/beige-cheetahs-provide.md create mode 100644 .changeset/clean-rules-itch.md delete mode 100644 packages/houdini-react/src/runtime/client.ts create mode 100644 packages/houdini-svelte/src/plugin/artifactData.ts create mode 100644 packages/houdini-svelte/src/runtime/client.ts create mode 100644 packages/houdini-svelte/src/runtime/imports/client.ts delete mode 100644 packages/houdini-svelte/src/runtime/network.ts delete mode 100644 packages/houdini-svelte/src/runtime/stores/store.ts create mode 100644 packages/houdini/src/codegen/generators/runtime/graphqlFunction.ts delete mode 100644 packages/houdini/src/codegen/generators/runtime/index.test.ts create mode 100644 packages/houdini/src/codegen/generators/runtime/injectPlugins.test.ts create mode 100644 packages/houdini/src/codegen/generators/runtime/injectPlugins.ts create mode 100644 packages/houdini/src/codegen/generators/runtime/pluginIndex.test.ts create mode 100644 packages/houdini/src/codegen/generators/runtime/pluginIndex.ts create mode 100644 packages/houdini/src/runtime/client/documentStore.test.ts create mode 100644 packages/houdini/src/runtime/client/documentStore.ts create mode 100644 packages/houdini/src/runtime/client/index.ts create mode 100644 packages/houdini/src/runtime/client/plugins/cache.test.ts create mode 100644 packages/houdini/src/runtime/client/plugins/cache.ts rename packages/houdini/src/runtime/{lib/networkUtils.ts => client/plugins/fetch.ts} (50%) create mode 100644 packages/houdini/src/runtime/client/plugins/fetchParams.ts create mode 100644 packages/houdini/src/runtime/client/plugins/index.ts create mode 100644 packages/houdini/src/runtime/client/plugins/injectedPlugins.ts create mode 100644 packages/houdini/src/runtime/client/plugins/mutation.ts create mode 100644 packages/houdini/src/runtime/client/plugins/query.ts create mode 100644 packages/houdini/src/runtime/client/plugins/subscription.ts create mode 100644 packages/houdini/src/runtime/client/plugins/throwOnError.ts create mode 100644 packages/houdini/src/runtime/client/utils/documentPlugins.ts create mode 100644 packages/houdini/src/runtime/client/utils/index.ts create mode 100644 packages/houdini/src/runtime/imports/config.ts delete mode 100644 packages/houdini/src/runtime/lib/errors.ts delete mode 100644 packages/houdini/src/runtime/lib/network.ts create mode 100644 packages/houdini/src/runtime/lib/store.ts create mode 100644 site/src/components/Zoomable.svelte create mode 100644 site/src/components/clickOutside.js create mode 100644 site/src/routes/api/client-plugins/+page.svx create mode 100644 site/src/routes/api/client-plugins/Authoring.svx create mode 100644 site/src/routes/api/client-plugins/Workflow.svelte create mode 100644 site/src/routes/api/client/+page.svx create mode 100644 site/src/routes/api/index.json create mode 100644 site/src/routes/guides/index.json create mode 100644 site/src/routes/intro/index.json create mode 100644 site/static/images/emojis/fear.png create mode 100644 site/static/images/emojis/scream.png diff --git a/.changeset/beige-cheetahs-provide.md b/.changeset/beige-cheetahs-provide.md new file mode 100644 index 0000000000..d82434651a --- /dev/null +++ b/.changeset/beige-cheetahs-provide.md @@ -0,0 +1,6 @@ +--- +'houdini': major +'houdini-svelte': major +--- + +Implemented new ClientPlugin architecture for HoudiniClient diff --git a/.changeset/clean-rules-itch.md b/.changeset/clean-rules-itch.md new file mode 100644 index 0000000000..2e5c429e62 --- /dev/null +++ b/.changeset/clean-rules-itch.md @@ -0,0 +1,5 @@ +--- +'houdini': patch +--- + +in queries when we have manual_load directive fetching is false by default otherwise true diff --git a/.eslintrc.cjs b/.eslintrc.cjs index eb0f999365..f0af885dcd 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -14,6 +14,13 @@ module.exports = { '@typescript-eslint/no-inferrable-types': 'off', '@typescript-eslint/prefer-as-const': 'off', '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/consistent-type-imports': [ + 'error', + { + prefer: 'type-imports', + fixStyle: 'separate-type-imports', + }, + ], 'unicorn/no-lonely-if': 'off', 'unicorn/filename-case': 'off', 'unicorn/no-instanceof-array': 'off', diff --git a/e2e/sveltekit/src/client.ts b/e2e/sveltekit/src/client.ts index 9b18b5108f..a15e097a01 100644 --- a/e2e/sveltekit/src/client.ts +++ b/e2e/sveltekit/src/client.ts @@ -1,40 +1,30 @@ -import type { RequestHandler } from '$houdini'; -import { HoudiniClient } from '$houdini'; +import { HoudiniClient, type ClientPlugin } from '$houdini'; +import { error } from '@sveltejs/kit'; -// For Query & Mutation -const requestHandler: RequestHandler = async ({ - fetch, - text = '', - variables = {}, - metadata, - session -}) => { - // Prepare the request - const url = 'http://localhost:4000/graphql'; +// in order to verify that we send metadata, we need something that will log the metadata after +const logMetadata: ClientPlugin = () => ({ + end(ctx, { resolve, value }) { + if (ctx.metadata?.logResult === true) { + console.info(JSON.stringify(value)); + } - // regular fetch (Server & Client) - const result = await fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${session?.user?.token}` // session usage example - }, - body: JSON.stringify({ - query: text, - variables - }) - }); - - // return the result as a JSON object to Houdini - const json = await result.json(); - - // metadata usage example - if (metadata?.logResult === true) { - console.info(JSON.stringify(json)); + resolve(ctx); } - - return json; -}; +}); // Export the Houdini client -export default new HoudiniClient(requestHandler); +export default new HoudiniClient({ + url: 'http://localhost:4000/graphql', + fetchParams({ session }) { + return { + headers: { + Authorization: `Bearer ${session?.user?.token}` // session usage example + } + }; + }, + throwOnError: { + operations: ['all'], + error: (errors) => error(500, errors.map((error) => error.message).join('. ') + '.') + }, + plugins: [logMetadata] +}); diff --git a/e2e/sveltekit/src/lib/QueryComponent.svelte b/e2e/sveltekit/src/lib/QueryComponent.svelte index 69ffd407fc..05fd9c430d 100644 --- a/e2e/sveltekit/src/lib/QueryComponent.svelte +++ b/e2e/sveltekit/src/lib/QueryComponent.svelte @@ -1,5 +1,5 @@ -
+