[2.0.2] apollo-client returns empty data during mutation | bug
See original GitHub issueI am not sure if it is related to apollo-client or react-apollo but I have this issue. During mutation I will get data without cached fields.
Here is steps how to reproduce it
- I have one component with graphql query which is loading user by his username. It is working great. data.user contains all information.
@graphql(gql`
query getQuestionContainerData($username: String!) {
user(username: $username) {
id
isViewer
cover
}
}
`, {
options: ({ match: { params: { username } } }) => ({
variables: {
username,
},
}),
})
- Second component is changing users photo (it has one mutation)
@graphql(gql`
mutation ($signed: String!) {
user: submitUserCoverS3DirectUpload(signed: $signed) {
id
canEdit
cover
}
}
`, {
name: 'submitUserCoverS3DirectUpload',
})
- First component will receive empty data.user (user is undefined) when second component starts mutation.
- After success mutation first component will receive correct data.user with all data.
My question is why I receive empty data.user ? Apollo client already have this data and I do not any clean cache.
My current deps:
"apollo-cache-inmemory": "^1.1.0",
"apollo-client": "^2.0.2",
"apollo-link": "^1.0.0",
"apollo-link-http": "^1.1.0",
"apollo-link-batch-http": "^1.0.0",
"apollo-link-retry": "^1.0.0",
"apollo-link-dedup": "^1.0.0",
"react-apollo": "^2.0.0",
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Mutations in Apollo Client - Apollo GraphQL Docs
You can use this to enable users to dismiss mutation result data or errors in the UI. Calling reset does not remove any...
Read more >Full Stack Error Handling with GraphQL and Apollo
If networkError is present in your response, it means your entire query was rejected, and therefore no data was returned.
Read more >Handling operation errors - Apollo GraphQL Docs
Apollo Client can encounter a variety of errors when executing operations on your ... If resolver errors occur, your server can still return...
Read more >Apollo Cache is completely empty as are my queries and ...
I am using Apollo dev tools, and my queries are empty, on pages that are rendering queries, and my mutations are empty when...
Read more >React-Apollo Mutation Returns Empty Response - ADocLib
Previously cached query should reflect changes in intersecting [2.0.2] apolloclient returns empty data during mutation | bug #2496.
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 Free
Top 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
I got the same issue and struggled a lot to find the source of it.
I traced it back to this part of the code which swallowed an error:
The result of my mutation was missing a field that was present in the original request.
Width
being missing, an error was thrown, catch by the previous code, and the objecthouse
ended undefined.I’m not sure of what I have done wrong.
I’m using the 2.1.0, so the code related to this PR is at least not covering all the cases.
@jbaxleyiii Can you reopen this issue?
Is this published? Because I am getting a similar error, below is before and after a mutation that happens in a deeply nested child component from the query component. Loading is false and no error on data.
First is check if object is null (node) Second line is props.data Third line is props.data.error.
Mutation happened