Last active
June 26, 2019 16:16
-
-
Save haldarmahesh/da2df518676a67582df65eb47e44c5c0 to your computer and use it in GitHub Desktop.
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
// src/controller/graphqlController.js | |
const graphqlHTTP = require('express-graphql'); | |
const { buildSchema } = require('graphql'); | |
// Construct a schema, using GraphQL schema language | |
const schema = buildSchema(` | |
type Query { | |
employee(id: Int!): Employee # `!` signifies this is mandatory | |
employees: [Employee], | |
} | |
type Mutation { | |
createEmployee(name: String!, department: String!): Employee, | |
deleteEmployee(id: Int!): DeleteEmployeeResponse | |
} | |
input EmployeeInput { | |
name: String!, | |
department: String! | |
} | |
type DeleteEmployeeResponse { | |
id: Int! | |
} | |
type Employee { | |
id: Int!, | |
name: String!, | |
department: String! | |
} | |
`); | |
// todo -> tie up this schema with GraphQL and the service to call one Query and Mutation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment