const { ApolloServer, gql } = require('apollo-server'); // Construct a schema, using GraphQL schema language const typeDefs = gql` type Query { hello: String order(orderId: String!): Order } type Order { id: String created: String updated: String eligibility: Boolean history: [HistoryRecord] } type HistoryRecord { message: String! } `; // Provide resolver functions for your schema fields const resolvers = { Query: { hello: (root, args, context) => { return 'Hello world!'; }, order: (_, { orderId }) => { return {id: orderId, created: "today", updated: "today"} } }, Order: { eligibility: (order) => { try { // call from order api, but fails throw new Error("oh noe"); } catch(e) { return e } } } }; const server = new ApolloServer({ typeDefs, resolvers }); server.listen().then(({ url }) => { console.log(`🚀 Server ready at ${url}`) });