-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
If variable limit is used in query for pagination, variable offset in the request will be null #446
Comments
Hey @Tamxaun! Sorry to hear you're running into this. Would you be able to put together a stackblitz that reproduces this issue? We have an integration test that verifies this behavior so it'd be really helpful to have something to compare to so we can see why you're situation is failing. |
I have created a repository on stackblitz. I used the public API to get the results. This example shows a problem with differences.
|
Thanks for putting that together! I'm struggling to find the time to dig into this while making sure we're ready for the new svelte kit API. If you have the energy to look into it, I'd love to help however I can. Feel free to reach out on discord if you want a more direct method of communication. |
@Tamxaun do you mind checking if this is still a problem in |
The new version does not appear to have any errors. However, using Demo on stackblitz This case scenario displays one item initially and then displays all items later. As an example, if I added default value # +page.gql
query SpacexHistories($limit: Int) {
histories(limit: $limit, sort: "event_date_utc") @paginate {
title
details
event_date_utc
}
} // +page.ts
import type { PageLoad } from './$types';
import { SpacexHistoriesStore } from "$houdini";
export const load: PageLoad = async (event) => {
const SpacexHistories = new SpacexHistoriesStore();
const result = await SpacexHistories.fetch({ event, variables: { limit: 1 } });
console.log('do something with', result);
return { SpacexHistories }
} |
Hey @Tamxaun! Is there a reason you are defining your load manually when you use a |
I forked the code sandbox example, removed the |
I thought I had to create a file +page.js with a load function to pass the required variables. Houdini makes its own load function, but how do we pass variables to the query? |
The runtime should tell you what is missing.
Then you can add again import type { SpacexHistoriesVariables as Variables } from './$houdini';
export const SpacexHistoriesVariables: Variables = async ({ params }) => {
// logic to get the limit... maybe from param? Maybe something else?
const limit = params.limit || '1'
return { limit };
}; The idea is to focus on what matters to you: variables. Let us know |
After trying, I found that if variables are not required in the query file, the result remains the same as described above 🤔 Also,
In addition, sometimes an error occurs about
|
Do you mind sharing your query? Also, #542 will fix a lot of strange behavior with the layout files. |
This is my query, and demo on codesandbox.io shows the issue as well. query SpacexHistories($limit: Int!) {
histories(limit: $limit, sort: "event_date_utc") @paginate {
title
details
event_date_utc
}
} |
Okay, i was able to reproduce this 🎉 I'll try to figure out what's going on. Just to confirm - if you define your query like this, it works?
edit for a little more context: if you define the |
The original bug should now be fixed in |
The following happens when I call loadNextPage on the Query Store and my query has variable limit and is not written by default (otherwise it's working correctly):
Query file:
Svelte file:
The text was updated successfully, but these errors were encountered: