apollo-client: @defer not working in React Native
Issue Description
When calling client.query({...}) in a redux action, this returns an error “Error: [TypeError: Cannot read property ‘length’ of undefined]” whenever @defer is used in the query.
For instance, giving a query like so:
const GET_USERS = gql`
query users($first: Int, $last: int, $id: int) { // im using relay connection args in BE for pagination
users(first: $first, last: $last, id: $id) {
pageInfo {
endCursor
}
edges {
node {
name
image_url
... @defer {
subscriptions {
status
}
}
}
}
}
}
`
And i have a redux action like so:
const getUsers = async () => {
const response = await client.query({
query: GET_USERS,
})
// application doesnt return a response or anything
// simply returns Error: [TypeError: Cannot read property 'length' of undefined] in console
}
@apollo/server: “4.3.0”
The reproduction repo doesnt currently use redux, but will add redux later today. Thought this is something the team may have seen before hence why I’m creating this. I can confirm @defer works just fine with useQuery. However, we’re using redux and abstracting apolloClient for use in all our actions which has always worked.
Link to Reproduction
https://github.com/bwoodlt/rn-apollo-client-testbed
Reproduction Steps
No response
@apollo/client version
3.9.2
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 20 (11 by maintainers)
@bwoodlt Great to hear that you found it! I’m sorry I couldn’t really help more here!
Took me a while to pull these together…
Using the
requestDidStartanddidEncounterErrorsplugins on the server, the client sends this formatches:The client doesnt actually show the query text, when you breakdown the
queryparam, this is what you get, this is even withApolloLinklogging outgoing requests:I noticed the hash expected with
getMatches2245c8cf69b6f71af947bdbf11370c4e303daaf848d7c83bf3049cf031bf308665 on the server is different from what client is sending i.e 45c8cf69b6f71af947bdbf11370c4e303daaf848d7c83bf3049cf031bf308665. The question is, how does it attach a different hash value and how do I obtain this if the client is expecting a hashfunctionto be provided?