Skip to content

Commit 75340e3

Browse files
committed
Basic setup
1 parent 3b92c7d commit 75340e3

4 files changed

Lines changed: 62 additions & 0 deletions

File tree

graphQL/.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env"
4+
]
5+
}

graphQL/data/schema.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { buildSchema } from "graphql";
2+
3+
const schema = buildSchema(`
4+
type Query {
5+
hello: String
6+
}
7+
`)
8+
9+
export default schema

graphQL/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import express from "express";
2+
import graphqlHTTP from "graphql-express"
3+
import schema from "./data/schema.js";
4+
5+
const app = express()
6+
7+
const PORT = 8080
8+
9+
app.get('/', (req, res) => {
10+
res.send("GraphQL")
11+
})
12+
13+
const root = { hello: () => "Hi form graphql" }
14+
15+
app.use('/graphql', graphqlHTTP({
16+
schema: schema,
17+
rootValue: root,
18+
graphiql: true,
19+
}))
20+
21+
app.listen(PORT, ()=> {
22+
console.log(`Running server at: ${PORT}`)
23+
})

graphQL/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "graphql",
3+
"version": "1.0.0",
4+
"description": "",
5+
"type": "module",
6+
"main": "index.js",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"start": "nodemon ./index.js --exec babel-node -e js"
10+
},
11+
"keywords": [],
12+
"author": "Nikos Konstantakis",
13+
"license": "ISC",
14+
"dependencies": {
15+
"express": "^4.19.2",
16+
"graphql": "^16.8.1",
17+
"graphql-express": "^3.0.0"
18+
},
19+
"devDependencies": {
20+
"@babel/cli": "^7.24.1",
21+
"@babel/core": "^7.24.4",
22+
"@babel/node": "^7.23.9",
23+
"@babel/preset-env": "^7.24.4"
24+
}
25+
}

0 commit comments

Comments
 (0)