Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // const { ApolloServer } = require("apollo-server");
- // const path = require("path");
- // const { makeSchema } = require("nexus");
- // const types = require("./graphql/schema");
- // const schema = makeSchema({
- // types,
- // outputs: {
- // schema: path.join(__dirname, "/graphql/generated/schema.graphql"),
- // typegen: path.join(__dirname, "/graphql/generated/typings.ts"),
- // },
- // });
- // const server = new ApolloServer({
- // schema,
- // });
- // server.listen().then(({ url, server }) => {
- // console.log(`Server is running on ${url}`)
- // })
- // .catch(err => {
- // console.log('something is wrong: ', err);
- // })
- const { ApolloServer, gql } = require('apollo-server');
- const books = [
- {
- title: 'Harry Potter and the Chamber of Secrets',
- author: 'J.K. Rowling',
- },
- {
- title: 'Jurassic Park',
- author: 'Michael Crichton',
- },
- ];
- const typeDefs = gql`
- type Book {
- title: String
- author: String
- }
- type Query {
- books: [Book]
- }
- `;
- const resolvers = {
- Query: {
- books: () => books,
- },
- };
- const server = new ApolloServer({ typeDefs, resolvers });
- server.listen().then(({ url }) => {
- console.log(`Server is running on ${url}`)
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement