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/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 0000000000..e4a858d97a --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,17 @@ +{ + "mode": "pre", + "tag": "next", + "initialVersions": { + "e2e-api": "1.0.0", + "e2e-next": "0.1.0", + "sveltekit": "0.0.1", + "example-kit": "0.13.0", + "scripts": "1.0.0", + "houdini": "0.20.2", + "houdini-plugin-svelte-global-stores": "0.20.2", + "houdini-react": "0.20.2", + "houdini-svelte": "0.20.2", + "site": "0.0.1" + }, + "changesets": [] +} 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 @@ -
+