Expected outcome:
If a field is missing from a child object of query results, I expect:
Actual outcome:
If a field is missing from a child object of a query:
How to reproduce the issue:
See this [react apollo error template] for a working recreation of the issue, with embedded notes
Notes
I am a big fan of Apollo Client 3. Debugging Queries that are not working due to to missing fields is the single most frequent (and time-consuming) issue I run into with AC3. The difficulty of troubleshooting these issues increases a great deal with complex and deep graphs.
The @apollo-client source already looks to have missing field tracking capabilities. For some reason this does not seem to bubble up (and I am not familiar enough with the source to figure out why)
Currently, the only way I have found to reveal the underlying missing field messages is to manually add console logging to the line 160 of the readFromStore.js file in the @apollo-client package, which is not a great user experience. (Maybe I am missing some obvious way to reveal these messages?)
Anything that can make this experience better would be a big help.
Versions
System:
OS: macOS 10.15.3
Binaries:
Node: 13.7.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.6 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.130
Safari: 13.0.5
npmPackages:
@apollo/client: 3.0.0-beta.37 => 3.0.0-beta.37
We hear you, and we are working on this currently. Thanks for the reproduction!
Ah, I suspect this issue might be the root cause of https://github.com/apollographql/apollo-client/issues/5963 as well
Maybe its the cause of https://github.com/apollographql/react-apollo/issues/3816 too
I believe this will be solved by #6221. Have a look if you're curious, and thanks for your patience!
@benjamn - that looks like a lot of work, and some good improvements! The fetchPolicy switch statement is definitely a big help in making the codebase more understandable. Pseudocode-style-coding is great for readability. Thanks for persisting.
I'm facing the same issue, but in beta-44 i've got a warning that field is missing.
To fix this I query the same fields set in both queries.
Example (note the title
field):
query list {
list {
name
image {
title
url
}
}
}
query image {
image
# title <- title was missed in in second query
url
}
}
And I don't know if this is important, but the socond query is resolved though fieldsPolicy
AKA cacheRedirects
.
@ElForastero if these are your actual queries, isn’t the warning rather because your objects don’t have ids ?
I'm having a similar issue...
I'm building a kanban board so it has several columns (this query is called once for each column, or stage)
I have this query
import gql from 'graphql-tag';
import projectFragment from 'ApolloClient/Fragments/projectFragment';
export default gql`
query projectsByStage($pipelineId: ID!, $stage: Int!) {
projectsByStage(pipelineId: $pipelineId, stage: $stage) {
...projectFragment
}
}
${projectFragment}
`;
//// another file
import gql from 'graphql-tag';
export default gql`
fragment projectFragment on Project {
id
__typename
title
description
projectType
pipeline
stage
}
`;
cache looks like this before an update
Note I have 7 projectsByStage queries, because in this case I have 7 kanban columns
and like this after an update
The single project is successfully moved from one query result (or column) to another using writeQuery. I've also checked this by running readQuery after I do the writeQuery.
But, my query is not rerendering the component...
I'm not sure what I'm overlooking...
"apollo-cache-inmemory": "^1.6.5",
"apollo-client": "^2.6.8",
"apollo-link": "^1.2.11",
"apollo-link-error": "^1.1.10",
"apollo-link-http": "^1.5.14",
"apollo-link-logger": "^1.2.3",
"apollo-link-retry": "^2.2.13",
"apollo-link-timeout": "^1.2.1",
"apollo-upload-client": "^13.0.0",
@mobiware I've simplified the examples. I have identifiers in entities and the warning was exactly about missed title
field in the cache.
@benjamn, @hwillson - I have verified that the issue I originally opened this ticket for is now solved. The query no longer silently fails, but instead produces a useful error message.
Others on this thread seem to have questions, so I am not sure what the protocol on closing the ticket or leaving open is. I shall leave to you.
Thanks for taking care of the core issue. This will be a massive productivity boost when working with AC3
Most helpful comment
@benjamn, @hwillson - I have verified that the issue I originally opened this ticket for is now solved. The query no longer silently fails, but instead produces a useful error message.
Others on this thread seem to have questions, so I am not sure what the protocol on closing the ticket or leaving open is. I shall leave to you.
Thanks for taking care of the core issue. This will be a massive productivity boost when working with AC3