I have the following query:
export const ReportModuleProperties = gql`
fragment ReportModuleProperties on ReportModule {
__typename
id
content
name
}
`;
export const REPORT_MODULE_BY_ID = gql`
query ReportModuleById($id: ID!) {
reportModuleById(id: $id) {
...ReportModuleProperties
}
}
${ReportModuleProperties}
`;
At some point I write a Report Module to the cache:
apolloClient.writeQuery<ReportModuleById, ReportModuleByIdVariables>({
query: REPORT_MODULE_BY_ID,
data: { reportModuleById: reportModule },
variables: { id: reportModule.id }
});
Then later I try to read it back from the cache using readQuery
:
client.readQuery<ReportModuleById, ReportModuleByIdVariables>({
query: REPORT_MODULE_BY_ID,
variables: {id: moduleId}
})
I use writeQuery
and readQuery
the same way successfully throughout the application. But this time I see an error saying: 'Can't find field reportModuleById on ROOT_QUERY object'.
The strange part is that the data is actually in the cache:
I try to wrap my head around this for days now, is there anything I miss here?