Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typings of loadAll() function #1209

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading