Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Inherit resolvers from graphql interface with Apollo Server v3

I would like to inherit resolvers from a graphql interface.

Consider this schema.

const typeDefs = gql`
  interface Name {
    name: String!
    surname: String!
  }

  type Person implements Name {
    _id: ID!
    name: String!
    surname: String!
  }

  type Query {
    getPerson: Person!
  }
}

And these resolvers:

const queryResolver = {
  Name: {
    name: () => "John",
    surname: () => "Doe"
  },

  Query: {
    getPerson: async (parent, args, context, info) => {
      return {
        _id: "1",
      };
    },
  }
}

This is my server

const { ApolloServer } = require("apollo-server");

const typeDefs = require("./types");
const queryResolvers = require("./resolvers/query");

const resolvers = {
  Query: queryResolvers.Query,
  Name: queryResolvers.Name,
};
try {
  const server = new ApolloServer({
    typeDefs,
    resolvers,
  });
  server.listen().then(({ url }) => {
    console.log(`Apollo server listening on ${url}`);
  });
} catch (e) {
  console.error(e);
}

I would like that when querying the server

query Query {
  getPerson {
    name
    surname
  }
}

I get John Doe, as I would expect that Person inherits the resolvers from Name.

On ApolloServer v.2 I get this functionality implemented through inheritResolversFromInterfaces https://www.apollographql.com/docs/apollo-server/v2/api/graphql-tools/

I have not been able to find and equivalent on ApolloServer v3.0

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!