0

I've run into an issue where Apollo client and the GQL playground return different data with the exact same query. The schema looks something like this:

interface A {
  age: Int!
}

interface B implements A {
  age: Int!
  name: String!
}

type SomeType implements A & B { ... }

type Query {
  hello: A 
}

The server returns a concrete type SomeType, which implements both interface A and B.

The query:

{
  hello {
    age
    ... on B {
       name
    }
  }
}

(The only difference I can think of is that when using Apollo client, the query is parsed with the graphl-tag). In the GQL playground, the query returns the expect result. Something like:

{
  "__typename": "someType",
  "age": 10,
  "name": "someName"
}

However, when running this query with Apollo client, I get:

{
  "__typename": "someType",
  "age": 10,
}

1 Answer 1

0

It seems the query is defined to return type A

type Query {
  hello: A 
}

So getting only the fields defined in A seems correct. Perhaps you should change the schema to something like:

type Query {
  hello: SomeType 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.