Let's take the order-ms service as an example and set up GraphQL there. First, we will need to install some dependencies:
$ npm install --save apollo-server-express graphql-tools graphql
Then, we need to create a new file called graphql.ts under src/graphql, with the following content:
import { ApolloServer, gql } from 'apollo-server-express'export class GraphQL { public typeDefs: string public resolvers: Object public server: ApolloServer constructor() { this.typeDefs = gql` type Query { hello: String } ` this.resolvers = { Query: { hello: () => 'Hello world!', }, } this.server = new ApolloServer({ typeDefs: this.typeDefs, resolvers: this.resolvers, }) } public setup(app): void { this.server.applyMiddleware({ ...