Created
June 17, 2016 09:38
-
-
Save freddi301/0c04eed646a0f8b31ab6042599b2c6f6 to your computer and use it in GitHub Desktop.
GraphQL Node Hello World with thron
This file contains hidden or 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
| const g = require('graphql'), | |
| graphql = g.graphql, | |
| GraphQLSchema = g.GraphQLSchema, | |
| GraphQLObjectType = g.GraphQLObjectType, | |
| GraphQLString = g.GraphQLString | |
| const schema = new GraphQLSchema({ | |
| query: new GraphQLObjectType({ name: 'RootQueryType', fields: { | |
| hello: { type: GraphQLString, resolve() { return 'world'; } }, | |
| ciao: { type: GraphQLString, resolve(){return Promise.resolve("heila")} } | |
| }}), | |
| mutation: new GraphQLObjectType({ name: 'RootMutationType', fields: { | |
| hello: { type: GraphQLString, resolve() { return 'gur'; } }, | |
| ciao: { type: GraphQLString, resolve(){return Promise.resolve("bil")}} | |
| }}) | |
| }); | |
| /*graphql(schema, 'mutation { hello ciao }').then(result => { | |
| console.log(result); | |
| });*/ | |
| const express = require('express'), | |
| throng = require('throng'), | |
| graphqlHTTP = require('express-graphql') | |
| throng(()=>{ | |
| const app = express() | |
| app.use('/graphql', graphqlHTTP({ schema, graphiql: true })); | |
| app.listen(7777, ()=>console.log("listening")) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment