Description
Intended outcome:
When running a query of the format
query AllPeople {
people {
id
name
}
...PeopleTypes
}
fragment PeopleTypes on Query {
__type(name: "Person") {
name
kind
}
}
The query executes and writes its contents to the internal cache, as it does for the same query with the fragment X on Query
inlined into the actual query { }
Actual outcome:
Error Cannot match fragment because __typename property is missing:
occurs
How to reproduce the issue:
I have a minimal reproduction case:
https://codesandbox.io/s/apolloclienterrortemplate-uoiq6
In the minimal case, manually adding __typename
to the fragment on Query
resolves the problem, however this is not the case in my application. I have not worked out why there is a difference here.
You'll note from playing around that the problem is specifically from fetching __type
, or __schema
in the Query fragment. If you instead fetch an aliased people
field the problem goes away.
In my App's case, I am pulling multiple EnumTypes by alias:
fragment MyFragment on Query {
movingOpennessOption: __type(name: "CareRecipientMoving") {
...enumValues
}
movingReasonOption: __type(name: "CareRecipientMovingReason") {
...enumValues
}
}
fragment enumValues on __Type {
enumValues {
name
description
}
}
Versions
"apollo-cache-inmemory": "^1.6.0",
"apollo-client": "^2.6.0",
"apollo-link": "^1.2.11",
"graphql": "^14.2.0",
"graphql-tag": "^2.10.1",
"react": "^16.8.6",
"react-apollo": "2.5.3",
"react-dom": "^16.8.6"
Activity