GraphQL CRUD Operations in Node.js, Axios, VanillaJS
$ git clone https://github.com/zinirun/graphql-crud-demo
$ cd ./graphql-crud-demo
$ npm install # yarn install
mutation addProduct($input: ProductInput) {
addProduct(input: $input)
}
{ getProduct(id : ?) { id price name description} }
mutation updateProduct($id: ID!, $input: ProductInput!){
updateProduct(id: $id, input: $input)
}
mutation deleteProduct{
deleteProduct(id: ${id})
}
- Get all items
- Debouncing Search (customized timer)
- Set data-set default
- GraphQL Server
/src/schema.js
- Build-Schema defined/src/rootValue.js
- Mutations and queries implemented/src/products.js
- Shared data accessed from gql/src/defaultProducts.js
- Default data-set
- Express
/app.js
- Express instance defined/server.js
- Server started from/app.js
- Client
/static/mod.js
- DOM Initialized, all events added/static/crud.js
- Events implemented/static/graphiql.js
- Iframe for GraphiQL(GUI)
Hard-coded dataset /src/defaultProducts.js
can be replaced by with Redis, etc...