Last active
May 4, 2020 04:58
-
-
Save iliran11/89162261c1d558659752e72b35b640d5 to your computer and use it in GitHub Desktop.
internationalize graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const { ApolloServer, gql } = require("apollo-server-express"); | |
const cookieParser = require("cookie-parser"); | |
const bodyParser = require("body-parser"); | |
// Construct a schema, using GraphQL schema language | |
const typeDefs = gql` | |
type Query { | |
greeting: String | |
id: Int | |
} | |
`; | |
// Provide resolver functions for your schema fields | |
const resolvers = { | |
Query: { | |
greeting: () => "Hello world!", | |
id: () => 1, | |
}, | |
}; | |
const server = new ApolloServer({ | |
typeDefs, | |
resolvers | |
}); | |
const app = express(); | |
app.use(cookieParser()); | |
server.applyMiddleware({ app }); | |
app.listen({ port: 4000 }, () => | |
console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment