Skip to content

Instantly share code, notes, and snippets.

@iliran11
Last active May 4, 2020 04:58
Show Gist options
  • Save iliran11/89162261c1d558659752e72b35b640d5 to your computer and use it in GitHub Desktop.
Save iliran11/89162261c1d558659752e72b35b640d5 to your computer and use it in GitHub Desktop.
internationalize graphql
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