import { AuthInfo } from "@pie-api-gcp/shared/auth"; import { getLogger } from "@pie-api-gcp/shared/logging"; import { gql } from "apollo-server"; import { GraphQLSchemaFactory, GraphQLSchemaElements } from "../types"; const logger = getLogger(); const Schema = gql` type Query { ping(message: String!): String! } type Mutation { ping(message: String!): String! } `; // in order to extend Query and Mutation elsewhere, we need a 'root' object for both, which // unfortunately can't be defined empty const schemaFactory: GraphQLSchemaFactory = async (token: AuthInfo): Promise => ({ typeDefs: [Schema], resolvers: { Query: { ping: (obj, args, context, info) => { return `Pong ${args.message}!`; }, }, Mutation: { ping: (obj, args, context, info) => { return `Pong ${args.message}!`; }, }, }, }); export default schemaFactory;