Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jdgabriel/graphql-todo-subscription
GraphQL Subscription usage with ToDo example
https://github.com/jdgabriel/graphql-todo-subscription
apollo-server graphql graphql-subscriptions nodemon
Last synced: 10 days ago
JSON representation
GraphQL Subscription usage with ToDo example
- Host: GitHub
- URL: https://github.com/jdgabriel/graphql-todo-subscription
- Owner: jdgabriel
- Created: 2019-10-29T22:49:34.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T11:22:54.000Z (almost 2 years ago)
- Last Synced: 2024-04-28T06:04:14.348Z (7 months ago)
- Topics: apollo-server, graphql, graphql-subscriptions, nodemon
- Language: JavaScript
- Homepage:
- Size: 363 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL Subscription Coding
Basic GraphQL TODO, for study library graphql subscription
## Installation
```
git clone https://github.com/jdgabriel/graphql-ToDo
cd graphql-ToDo
yarn install
```# Queries
### [Query] All Todo
```
query all {
todos {
id
task
complete
}
}```
##### Response
```javascript
{
"data": {
"todos": [
{
"id": "1",
"task": "Read About graphql",
"complete": true
}
]
}
}
```### [Mutation] Create a new Todo
##### Query
```
mutation new {
newTodo(data: { task: "Buy Coffe", complete: false }) {
mutation
node {
id
task
complete
}
}
}
```##### Response
```json
{
"data": {
"newTodo": {
"mutation": "CREATED",
"node": {
"id": "2",
"task": "Buy Coffe",
"complete": false
}
}
}
}
```### [Mutation] Edit Todo
Use id field for update Todo
##### Query
```
mutation edit {
editTodo(
fields: { task: "Bath in the cat", complete: true }
where: { id: "1" }
) {
mutation
node {
id
task
complete
}
}
}
```##### Response
```javascript
{
"data": {
"editTodo": {
"mutation": "UPDATED",
"node": {
"id": "2",
"task": "Bath in the cat",
"complete": true
}
}
}
}
```### [Mutation] Remove Todo
Use id field for update Todo
```
mutation remove {
removeTodo(where: {id: "2"})
}
```##### Response
```javascript
{
"data": {
"removeTodo": true
}
}
```# Subscriptions
Subscriptions are based on three nodes
- CREATED
- UPDATED
- REMOVED```
subscription {
todo(mutation: UPDATED) {
mutation
node {
id
task
complete
}
}
}
```##### Response
```javascript
{
"data": {
"todo": {
"mutation": "UPDATED",
"node": [...]
}
}
}
```### License MIT
Gabriel Duarte