-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
relayStylePagination returns undefined for non-paginated query on field #6611
Comments
Ahh, I think I know what this is. The |
what is the purpose of makeEmptyData() on the read function? I'm finding it's causing problems in my react app where the makeEmptyData() is preventing queries from hitting the backend under certain circumstances (I believe it's priming the cache with empty results) |
Fixes #6611, thanks to this astute comment from @fracmak: #6611 (comment) Returning undefined from a field read function indicates to the StoreReader that the field is missing, and usually means the query will be fetched from the server. When we haven't yet written any data to a field paginated using relayStylePagination, requesting data from the server is almost always better than providing any kind of default information, so we should avoid using makeEmptyData() as a default value.
…#6684) Fixes #6611, thanks to this astute comment from @fracmak: #6611 (comment) Returning undefined from a field read function indicates to the StoreReader that the field is missing, and usually means the query will be fetched from the server. When we haven't yet written any data to a field paginated using relayStylePagination, requesting data from the server is almost always better than providing any kind of default data, so we should avoid using makeEmptyData() as a default value for the existing parameter.
@benjamn
It'll crash in |
I patched it with:
|
Also running into issues after querying for only totalCount. Tried this patch and version 3.2.0.beta-7 but still couldn't get reliable updates. It seems if you first query without any edges/pageInfo
And then query for the edges
The users will always be an empty and return no data. |
Intended outcome:
Expecting results to come back when querying a
relayStylePagination
field for justtotalCount
. E.g:Actual outcome:
Both
data
anderror
come back asundefined
after migrating torelayStylePagination
fromupdateQuery
.How to reproduce the issue:
relayStylePagination
setup like so:When querying for
usersCount
above, thendata
anderror
both come back asundefined
.updateQuery
was previously on each call, so it didn't apply to this query.Versions
@apollo/client: 3.0.0
The text was updated successfully, but these errors were encountered: