Last active
June 14, 2018 13:49
-
-
Save dhavaln/63434d23d72b0515921de9402452cdb5 to your computer and use it in GitHub Desktop.
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
const express = require('express'); | |
const graphql = require('express-graphql'); | |
const graphqlTools = require('graphql-tools'); | |
const app = express(); | |
// Sample Data | |
const blogsData = [{_id: 1, title: 'Hello', content: 'World'}]; | |
// Simple Blog schema with ID, Title and Content fields | |
const typeDefs = ` | |
type Blog{ | |
_id: Int, | |
title: String!, | |
content: String! | |
} | |
`; | |
// Resolver to match the GraphQL query and return data | |
const resolvers = {}; | |
// Build the schema with Type Definitions and Resolvers | |
const schema = graphqlTools.makeExecutableSchema({typeDefs, resolvers}); | |
app.use('/graphiql', graphql({ | |
graphiql: true, | |
schema | |
})); | |
app.listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment