npm 프로젝트로 만들어준다.
$ npm init -y
$ npm i apollo-server graphql
소스 코드를 수정했을 때 자동으로 서버를 새로고침 하기 위해 라이브버리 설치
$ npm i nodemon -D

<https://github.com/apollographql/apollo-server>
const { ApolloServer, gql } = require("apollo-server");

// The GraphQL schema
const typeDefs = gql`
  type Book {
    title: String
    author: String
  }

  type Query {
    books: [Book]
  }
`;

const books = [
  {
    title: "The Awakening",
    author: "Kate Chopin",
  },
  {
    title: "City of Glass",
    author: "Paul Auster",
  },
];

// A map of functions which return data for the schema.
const resolvers = {
  Query: {
    // books: () => books,
    books: () => [books[0], books[1]],
  },
};

const server = new ApolloServer({
  typeDefs,
  resolvers,
  playground: true,
});

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});