-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
Querying different fields on the same object in +layout and +page causes values to disappear in browser #1104
Comments
Is it a typo the |
ahh yes, I'm very sorry - I didn't catch that copy and paste mistake in my final minified test before leaving the office. So correcting that to I am waiting for the data to be loading in the load function so I can initialize superforms with the data. My +page.ts looks like this: import { load_PageQuery } from "$houdini";
import { formSchema } from "$lib/form-schemas/formSchema.schema";
import { waitForData } from "$lib/utils/graphql.util";
import { superValidate } from "sveltekit-superforms/server";
export const load = async (event) => {
const { PageQuery } = await load_PageQuery({ event });
const { tenant } = (await waitForData(PageQuery)) ?? {};
const form = await superValidate(tenant, formSchema);
return { form };
}; We had written a import type { GraphQLObject, GraphQLVariables, QueryStore } from "$houdini";
export const waitForData = async <Data extends GraphQLObject, Input extends GraphQLVariables>(
store: QueryStore<Data, Input>
) => {
return await new Promise<Data | null>((resolve) => {
store.subscribe(({ data }) => resolve(data));
});
}; This had been working fine, but when adding the +layout queries of the same object, subscribing to the +page query would first return source export const waitForData = async <Data extends GraphQLObject, Input extends GraphQLVariables>(
store: QueryStore<Data, Input>
) => {
return await new Promise<Data | null>((resolve) => {
store.subscribe(({ data, source, fetching }) => {
console.log(data, source);
if (
!fetching &&
((source === "cache" && data && Object.keys(data).every((key) => data[key])) ||
source === "network")
) {
resolve(data);
}
});
});
}; Which has "fixed" my use-case, but feels quite hacky. Is there a better way to wait for data in load functions to ease working with superforms? |
You could check out the const { PageQuery } = await load_PageQuery({ event, blocking: true }); |
That doesn't seem to have any effect. |
ahh but I have |
A "real await" should happen with const result = await load_PageQuery({ event, blocking: true }); |
Yes, that's what I had. I just tried with disabling Here with partial + blocking set to true:
And here with partial set to false and blocking set to true:
|
So I guess the issue is "solved" here, but maybe it is worth updating the docs regarding the usage of |
Describe the bug
It sounds similar to this issue #1020 but I am not using fragments, and even if i disable masking it doesn't seem to help.
If you run a query on an object in both +layout and +page then the values will be removed from the browser for the +page query.
Severity
serious, but I can work around it
Steps to Reproduce the Bug
query in +layout
query in +page
Both queries are run, but nothing is displayed in the in the page component:
Reproduction
No response
The text was updated successfully, but these errors were encountered: