Skip to content

Instantly share code, notes, and snippets.

@musebe
Forked from igaskin/Dockerfile
Created January 7, 2019 06:46
Show Gist options
  • Save musebe/41e2334452c2df28dae68f9904131d64 to your computer and use it in GitHub Desktop.
Save musebe/41e2334452c2df28dae68f9904131d64 to your computer and use it in GitHub Desktop.
Intro to GraphQL in Docker
version: '3'
services:
web:
build: .
ports:
- "4000:4000"
FROM node:7-alpine
COPY ./ /app
WORKDIR /app
CMD node hello.js
var express = require('express');
var graphqlHTTP = require('express-graphql');
var { buildSchema } = require('graphql');
// Construct a schema, using GraphQL schema language
var schema = buildSchema(`
type Query {
hello: String
}
`);
// The root provides a resolver function for each API endpoint
var root = {
hello: () => {
return 'Hello world!';
},
};
var app = express();
app.use('/graphql', graphqlHTTP({
schema: schema,
rootValue: root,
graphiql: true,
}));
app.listen(4000);
console.log('Running a GraphQL API server at localhost:4000/graphql');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment