Skip to content

Instantly share code, notes, and snippets.

@GeoffMahugu
Last active April 12, 2021 18:37
Show Gist options
  • Save GeoffMahugu/be3e32bf73dfa5402e9cbe9d43eedad1 to your computer and use it in GitHub Desktop.
Save GeoffMahugu/be3e32bf73dfa5402e9cbe9d43eedad1 to your computer and use it in GitHub Desktop.
This is a schema file for a GraphQL application to perform CRUD operations on a Product.
const { buildSchema } = require('graphql');
export default buildSchema(`
type Product{
_id:ID!
name: String!
description: StriWng!
price: Float!
discount: Int
created_at: String!
updated_at: String!
}
type ProductData {
products: [Product!]!
}
input ProductInputData {
name: String!
description: String!
price: Float!
discount: Int
}
type RootQuery {
products: ProductData!
}
type RootMutation {
createProduct(productInput:ProductInputData): Product!
updateProduct(id: ID!, productInput:ProductInputData): Product!
deleteProduct(id: ID!): Product!
}
schema {
query: RootQuery
mutation: RootMutation
}
`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment