- Run
npm install && npm start
- Load the web page in your browser. It will run at
http://localhost:8080
by default.
I see one item of type ExampleInterface
, including its typename, ID, and name. When I immediately
log the results of useQuery
, they match what I see in the network tab. It looks like this:
{
"__typename": "ExampleTypeB",
"id": "1",
"name": "Example Name"
}
I see one item with only a __typename
field.
This occurs when querying for an interface using a fragment.
I can work around it by not (A) using fragments or (B) using a fragment for each subtype. Both options are problematic.
const ExampleQuery = gql`
query {
exampleQuery {
__typename
id
name
}
}
`;
const ExampleQuery = gql`
fragment ExampleFragmentA on ExampleTypeA {
__typename
id
name
}
fragment ExampleFragmentB on ExampleTypeB {
__typename
id
name
}
query {
exampleQuery {
__typename
...ExampleFragmentA
...ExampleFragmentB
}
}
`;