Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Can't query interface types #414

Closed
gilesdring opened this issue Apr 17, 2020 · 1 comment · May be fixed by #456
Closed

Can't query interface types #414

gilesdring opened this issue Apr 17, 2020 · 1 comment · May be fixed by #456

Comments

@gilesdring
Copy link

I have the following schema

interface Person {
  id: ID!
  name: String
}

type A implements Person {
  id: ID!
  name: String
}

type B implements Person {
  id: ID!
  name: String
}

When I run a query of the type:

query {
  Person {
    name
  }
}

I get the following error from the server.

Abstract type \"Person\" must resolve to an Object type at runtime for field \"Query.Person\" with value { name: \"A Person\", FRAGMENT_TYPE: null }, received \"null\". Either the \"Person\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.

The full stacktrace is:

GraphQLError: Abstract type "Person" must resolve to an Object type at runtime for field "Query.Person" with value { name: "Giles Dring", FRAGMENT_TYPE: null }, received "null". Either the "Person" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.
    at ensureValidRuntimeType (/Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:687:11)
    at completeAbstractValue (/Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:680:42)
    at completeValue (/Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:604:12)
    at completeValueCatchingError (/Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:514:19)
    at /Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:636:25
    at from (<anonymous>)
    at completeListValue (/Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:632:49)
    at completeValue (/Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:592:12)
    at /Users/gilesdring/src/dringtech/eccoo/graph/api/node_modules/graphql/execution/execute.js:511:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

This seems similar to a few other issues, but not exactly. I'm using v2.13.0. The way I'm reading the documentation, it should work.

@gilesdring
Copy link
Author

I think this is an issue related to version 15 of graphql. I've reverted to 14.6.0 and it now seems to be working

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant