-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (23 loc) · 630 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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'));