1
votes

I am using graphql-tools to build a GraphQL Schema, esentially I have this structure

const typeDefs = `
type Query {
  author(name: String): Author
}
interface Person {
  id: Int 
  name: String
  citizenship: String
type Author implements Person {
  id: Int
  name: String
  citizenship: String
`

and I have the following resolvers

const resolvers = {
  Query: {
    author(_,args) {
        return Author.find({where: args});
    }
  }
  Person: {
    citizenship() {
      return "Example Citizenship";
    }
  }
}

I make the schema executable

const schema = makeExecutableSchema({
  typeDefs,
  resolvers,
  inheritResolversFromInterfaces: true
});

and the optional argument inheritResolversFromInterfaces: true its supposed to allow me to inherit the citizenship resolver from Person to Author, based on the apollo graphql-tools documentation (link). That way when an Author is queried, the "Example Citizenship" string will appear.

However it does not, the query returns with

"author": {
  "id": 1,
  "name": "Peter",
  "citizenship": null
} 
1
What version of graphql-tools are you using? That feature was only added with v2.24.0Daniel Rearden
I just checked and the version I was running is v2.8.0, I updated to v2.24.0 and now it works!Adolfo
Also, Apollo Server v2. now supports it out of the box!Le garcon

1 Answers

1
votes

Resolved, the feature inheritResolversFromInterfaces: true was added in version v2.24.0, need to have that version in order to use that feature.