Skip to content

Commit

Permalink
#1.1 Creating GraphQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
serranoarevalo committed Feb 12, 2019
1 parent fbe8b93 commit 591fd41
Show file tree
Hide file tree
Showing 4 changed files with 1,148 additions and 509 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
"author": "Nicolás Serrano Arévalo <itnico.las.me@gmail.com>",
"license": "MIT",
"dependencies": {
"@babel/core": "^7.2.2",
"@babel/node": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"dotenv": "^6.2.0",
"graphql-yoga": "^1.17.4"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"nodemon": "^1.18.10"
},
"scripts": {
Expand Down
22 changes: 22 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require("dotenv").config();
import { GraphQLServer } from "graphql-yoga";

const PORT = process.env.PORT || 4000;

const typeDefs = `
type Query{
hello: String!
}
`;

const resolvers = {
Query: {
hello: () => "Hi"
}
};

const server = new GraphQLServer({ typeDefs, resolvers });

server.start({ port: PORT }, () =>
console.log(`Server running on http://localhost:${PORT}`)
);

0 comments on commit 591fd41

Please sign in to comment.