-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
usePagination bug: loadNext doesn't work when using a custom identifier field #215
Comments
hi @Lalitha-Iyer, Can you edit the sample project (https://github.com/relay-tools/relay-hooks/tree/master/examples/relay-hook-example/pagination-nextjs-ssr) so that I can study the your case? |
sure thing, I will edit the project to have an example with a custom node id and try to repro the error. |
I tried setting up the example, but am struggling to configure relay compiler with nextjs. I will give it a try again this week, otherwise would it be ok if I shared a code-sandbox example. |
Hi, @morrys I was looking at the solution proposed in the relay PR, looks similar to what I suggested here. Besides pagination variable we would also have to fix refetchable variable here relay-hooks/src/FragmentResolver.ts Line 494 in 2cda9c6
I am assuming the comment about What are your thoughts on fixing this issue? I am also happy to submit a PR with the fix if it helps. |
Hi @Lalitha-Iyer, |
@morrys one workaround that seems to work is passing extra variables like so. Do you see any issues with doing this.
|
@morrys The PR in relay has been merged, whenever you get a chance could you revisit this issue. |
@Lalitha-Iyer As soon as relay releases PR with v16 version, I will modify relay-hooks in order to release v9 :) |
released with relay-hooks v9.0.0 |
Description:
We use a custom id field
_id
and have configured the relay compiler to use this custom field as id.useQuery
hook works fine however when using theusePagination
hook andloadNext
to fetch more items. I see the below error in the graphql response.message: "Variable '_id' has coerced Null value for NonNull type 'ID!'",…}
Fix
I could fix this locally by changing the
id
field in variables to be_id
. We probably want to useidentifierField
instead of a fixed key. Something along these lineshttps://github.com/relay-tools/relay-hooks/blob/master/src/FragmentResolver.ts#L644
The text was updated successfully, but these errors were encountered: