Skip to content

Instantly share code, notes, and snippets.

@dhavaln
Last active June 14, 2018 13:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dhavaln/63434d23d72b0515921de9402452cdb5 to your computer and use it in GitHub Desktop.
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