File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "presets" : [
3+ " @babel/preset-env"
4+ ]
5+ }
Original file line number Diff line number Diff line change 1+ import { buildSchema } from "graphql" ;
2+
3+ const schema = buildSchema ( `
4+ type Query {
5+ hello: String
6+ }
7+ ` )
8+
9+ export default schema
Original file line number Diff line number Diff line change 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+ } )
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments