-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ac3a3b1
Showing
4 changed files
with
829 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const express = require('express'); | ||
const { graphqlHTTP } = require('express-graphql'); | ||
const { buildSchema } = require('graphql'); | ||
const cors = require('cors') | ||
|
||
// Definisci uno schema GraphQL | ||
const schema = buildSchema(` | ||
type Query { | ||
hello: String | ||
} | ||
`); | ||
|
||
// Definisci un resolver | ||
const root = { | ||
hello: () => 'Hello world!' | ||
}; | ||
|
||
// Configura Express per usare GraphQL | ||
const app = express(); | ||
app.use(cors()); | ||
app.use('/graphql', graphqlHTTP({ | ||
schema: schema, | ||
rootValue: root, | ||
graphiql: true | ||
})); | ||
|
||
app.listen(4000, () => console.log('Server GraphQL in esecuzione su http:https://localhost:4000/graphql')); |
Oops, something went wrong.