HoudiniGraphql / houdini

The disappearing GraphQL framework

Home Page:http://www.houdinigraphql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Components Queries throw errors when SSR

doukai opened this issue · comments

Describe the bug

Components Queries throw errors when SSR

Severity

annoyance

Steps to Reproduce the Bug

1 this is my query store in componet

	export const _GroupNodesQueryVariables: GroupNodesQueryVariables = ({ props }) => {
		return {
			deep: { opr: Operator.LT, val: props.currentDeep + props.deeps },
			path: {
				opr: Operator.LK,
				val: `${(props.parent?.path || '') + (props.parent?.id || '') + '/'}%`
			}
		};
	};

	const GroupNodesQuery = graphql(`
		query GroupNodesQuery($path: StringExpression, $deep: IntExpression, $name: StringExpression)
		@load {
			groupList(deep: $deep, path: $path, name: $name) {
				id
				name
				path
				deep
				parentId
			}
		}
	`);

2 when client side query is ok

3 when server side query throws is:

@graphace/web:dev: [0]  Missing event args in load function.
@graphace/web:dev: [0] 
@graphace/web:dev: [0] Please remember to pass event to fetch like so:
@graphace/web:dev: [0] 
@graphace/web:dev: [0] import type { LoadEvent } from '@sveltejs/kit';
@graphace/web:dev: [0] 
@graphace/web:dev: [0] // in a load function...
@graphace/web:dev: [0] export async function load(event: LoadEvent) {
@graphace/web:dev: [0]  return {
@graphace/web:dev: [0]          ...load_GroupNodesQueryStore({ event, variables: { ... } })
@graphace/web:dev: [0]  };
@graphace/web:dev: [0] }
@graphace/web:dev: [0] 
@graphace/web:dev: [0] // in a server-side mutation:
@graphace/web:dev: [0] await mutation.mutate({ ... }, { event })
@graphace/web:dev: [0] 
@graphace/web:dev: [0] /Users/doukai/Work/graphace/apps/web/$houdini/plugins/houdini-svelte/runtime/stores/query.js:140
@graphace/web:dev: [0]     throw new Error("Error, check above logs for help.");
@graphace/web:dev: [0]           ^
@graphace/web:dev: [0] 
@graphace/web:dev: [0] Error: Error, check above logs for help.
@graphace/web:dev: [0]     at fetchParams (/Users/doukai/Work/graphace/apps/web/$houdini/plugins/houdini-svelte/runtime/stores/query.js:140:11)
@graphace/web:dev: [0]     at GroupNodesQueryStore.fetch (/Users/doukai/Work/graphace/apps/web/$houdini/plugins/houdini-svelte/runtime/stores/query.js:39:47)
@graphace/web:dev: [0] vite dev exited with code 1

Is there something wrong with my usage?
thanks

Reproduction

No response

commented

query store in componet

You mean not in a +page.svelte or +layout.svelte? in like GroupNodesQuery.svelte ?
If it's the case, Yes, it's not possible to do that.

Or you are by queries & components and you work in CSR.
Or you are by fragments & components and you do your queries at route level to have CSR & SSR.

Does it make sense?

query store in componet

You mean not in a +page.svelte or +layout.svelte? in like GroupNodesQuery.svelte ? If it's the case, Yes, it's not possible to do that.

Or you are by queries & components and you work in CSR. Or you are by fragments & components and you do your queries at route level to have CSR & SSR.

Does it make sense?

We should probably not allow @load directive in a Svelte component, but only to route components.

Thanks for the answer, I will try another way