Skip to content

Commit

Permalink
Fix typings of loadAll() function (#1209)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschortsch committed Oct 8, 2023
1 parent ef77ca1 commit 392bd24
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/soft-toes-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini-svelte': patch
---

Fix typings of loadAll() function
1 change: 1 addition & 0 deletions e2e/kit/src/lib/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script lang="ts">
import { HelloStore } from '$houdini';
import type { PageData } from './$houdini';
export let data: PageData;
$: ({ Hello } = data);
const checkTypes = () => {
return `${data.Hello instanceof HelloStore}`;
};
</script>

<h1>ssr-loadall-store-without-variables</h1>

<div id="result">
{$Hello.data?.hello}
</div>

<div id="result-types">
{checkTypes()}
</div>
Original file line number Diff line number Diff line change
@@ -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 }));
}
Original file line number Diff line number Diff line change
@@ -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]');
});
});
3 changes: 2 additions & 1 deletion packages/houdini-svelte/src/runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { GraphQLVariables } from '$houdini/runtime/lib/types'
import type { QueryStore } from './stores'

export * from './adapter'
Expand All @@ -6,7 +7,7 @@ export * from './fragments'
export * from './session'
export * from './types'

type LoadResult = Promise<{ [key: string]: QueryStore<any, {}> }>
type LoadResult = Promise<{ [key: string]: QueryStore<any, GraphQLVariables> }>
type LoadAllInput = LoadResult | Record<string, LoadResult>

// gets all the values from an object
Expand Down

0 comments on commit 392bd24

Please sign in to comment.