From 392bd2480132430bdf5c52197be956ea29858c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Hunziker?= Date: Sun, 8 Oct 2023 06:57:34 +0200 Subject: [PATCH] Fix typings of `loadAll()` function (#1209) --- .changeset/soft-toes-learn.md | 5 +++++ e2e/kit/src/lib/utils/routes.ts | 1 + .../+page.svelte | 22 +++++++++++++++++++ .../+page.ts | 6 +++++ .../spec.ts | 11 ++++++++++ packages/houdini-svelte/src/runtime/index.ts | 3 ++- 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .changeset/soft-toes-learn.md create mode 100644 e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.svelte create mode 100644 e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.ts create mode 100644 e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/spec.ts diff --git a/.changeset/soft-toes-learn.md b/.changeset/soft-toes-learn.md new file mode 100644 index 000000000..2d23ac8de --- /dev/null +++ b/.changeset/soft-toes-learn.md @@ -0,0 +1,5 @@ +--- +'houdini-svelte': patch +--- + +Fix typings of loadAll() function diff --git a/e2e/kit/src/lib/utils/routes.ts b/e2e/kit/src/lib/utils/routes.ts index 5638744b8..6794aca49 100644 --- a/e2e/kit/src/lib/utils/routes.ts +++ b/e2e/kit/src/lib/utils/routes.ts @@ -34,6 +34,7 @@ export const routes = { Stores_Mutation_Scalar_Multi_Upload: '/stores/mutation-scalar-multi-upload', Stores_Mutation_Enums: '/stores/mutation-enums', Stores_Network_One_Store_Multivariables: '/stores/network-one-store-multivariables', + Stores_SSR_LoadAll_Store_Without_Variables: '/stores/ssr-loadall-store-without-variables', Stores_SSR_One_Store_Multivariables: '/stores/ssr-one-store-multivariables', Stores_Fragment_Null: '/stores/fragment-null', Stores_Metadata: '/stores/metadata', diff --git a/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.svelte b/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.svelte new file mode 100644 index 000000000..f8fb19f3a --- /dev/null +++ b/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.svelte @@ -0,0 +1,22 @@ + + +

ssr-loadall-store-without-variables

+ +
+ {$Hello.data?.hello} +
+ +
+ {checkTypes()} +
diff --git a/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.ts b/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.ts new file mode 100644 index 000000000..07b62b4e8 --- /dev/null +++ b/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/+page.ts @@ -0,0 +1,6 @@ +import { load_Hello, loadAll } from '$houdini'; +import type { LoadEvent } from '@sveltejs/kit'; + +export async function load(event: LoadEvent) { + return await loadAll(load_Hello({ event })); +} diff --git a/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/spec.ts b/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/spec.ts new file mode 100644 index 000000000..6746237d8 --- /dev/null +++ b/e2e/kit/src/routes/stores/ssr-loadall-store-without-variables/spec.ts @@ -0,0 +1,11 @@ +import { test } from '@playwright/test'; +import { routes } from '../../../lib/utils/routes.js'; +import { expect_to_be, goto } from '../../../lib/utils/testsHelper.js'; + +test.describe('ssr-loadall-store-without-variables Page', () => { + test('loadAll should brings correct types', async ({ page }) => { + await goto(page, routes.Stores_SSR_LoadAll_Store_Without_Variables); + + await expect_to_be(page, 'true', 'div[id=result-types]'); + }); +}); diff --git a/packages/houdini-svelte/src/runtime/index.ts b/packages/houdini-svelte/src/runtime/index.ts index f598be3c5..7f4f49486 100644 --- a/packages/houdini-svelte/src/runtime/index.ts +++ b/packages/houdini-svelte/src/runtime/index.ts @@ -1,3 +1,4 @@ +import type { GraphQLVariables } from '$houdini/runtime/lib/types' import type { QueryStore } from './stores' export * from './adapter' @@ -6,7 +7,7 @@ export * from './fragments' export * from './session' export * from './types' -type LoadResult = Promise<{ [key: string]: QueryStore }> +type LoadResult = Promise<{ [key: string]: QueryStore }> type LoadAllInput = LoadResult | Record // gets all the values from an object