query results are undefined during loading (due to breaking change in @apollo/client v3)
See original GitHub issueThere was an intentional breaking change in Apollo Client 3.0.0.
When refetching or when using loadMore, results
and totalCount
revert temporarily to undefined
.
For in-depth information and debate, see threads like
- https://github.com/apollographql/apollo-client/blob/46706b53cd36a073800e9abbd4788d0b72c0dab2/CHANGELOG.md#react,
- https://github.com/apollographql/apollo-client/issues/7038#issuecomment-694569198
- https://github.com/apollographql/apollo-client/issues/6603
It could impact Vulcan in a number of ways, but so far I have only been looking at multi2.js
. See Vulcan discussion at https://vulcanjs.slack.com/archives/C2LJQHTLP/p1601657376018800
A possible solution is to update to @apollo/client@3.3.0-beta.6
and override useQuery
. Or change https://github.com/VulcanJS/Vulcan/blob/78d0e99dd8cde19b6da04561c27a8e040ef8ae7f/packages/vulcan-core/lib/modules/containers/multi2.js#L110-L113 to something like this:
const { refetch, networkStatus, error, fetchMore, graphQLErrors, data, previousData } = returnedProps
const existingData = data ?? previousData
const results = existingData && existingData[resolverName] && existingData[resolverName].results;
const totalCount = existingData && existingData[resolverName] && existingData[resolverName].totalCount;
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Migrating to Apollo Client 3.0 - Apollo GraphQL Docs
Breaking Changes : useQuery no longer maintains the previously fetched results in its data result when loading new data. Instead, when new data...
Read more >@apollo/client - Awesome JS
Revert use of cloneDeep to clone options when fetching queries. ... whose addition in #8699 was a breaking change (starting in Apollo Client...
Read more >@apollo/client | Yarn - Package Manager
@apollo/client. 3.7.3. Patch Changes. #10334 7d923939d Thanks @jerelmiller! - Better handle deferred queries that have cached ...
Read more >Migrating to React Query 4 - TanStack
Breaking Changes v4 is a major version, so there are some breaking ... cases that cannot be found by the code mod, so...
Read more >Integrating GraphQL Code Generator in your frontend ...
We can't count of the fields to be there because they GraphQL query can change, and it's not connected to our code at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
results
is a Vulcan specific shortcut (btw in NPM version I renamed itdocuments
for consistency with mutations) so we are free to implement whatever default behaviour we want, no need for an option, and I think what you proposed is the best approach as it prevents a breaking change in Vulcan. People can still access the defaultdata
object from Apollo if they want the default behaviour.I’m using oldschool react classes, so keep the results in component state. Then I check and update the results in
componentDidUpdate
, and render from the state’s copy:Then showing loading state based on whether there are results:
It’s not ideal but does the trick for now