https://github.com/maxzz/test-graphql
GraphQL server test implementation.
https://github.com/maxzz/test-graphql
Last synced: 3 months ago
JSON representation
GraphQL server test implementation.
- Host: GitHub
- URL: https://github.com/maxzz/test-graphql
- Owner: maxzz
- Created: 2020-03-16T03:45:58.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T05:32:59.000Z (over 2 years ago)
- Last Synced: 2025-01-08T21:20:21.199Z (5 months ago)
- Language: JavaScript
- Size: 112 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Description
Testing the GraphQL server implementation.
## Use
Run ```yarn dev``` and open ```localhost:4000```
## Queries and mutations
##### Ask highlights
Query all records
```js
query {
highlights {
id
content
title
author
}
}
```or just some fields
```js
query {
highlights {
title
author
}
}
```Result:
```js
{
"data": {
"highlights": [
{
"title": "Dharma Bums",
"author": "Jack Kerouac"
},
{
"title": "Arbitrary Stupid Goal",
"author": "Tamara Shopsin"
}
]
}
}
```##### Query for an individual note by including an ID parameter with our query
```js
query {
highlight(id: "1") {
content
}
}
```Result:
```js
{
"data": {
"highlight": {
"content": "One day I will find the right words, and they will be simple."
}
}
}
```
##### Mutation: Add Record
```js
mutation {
newHighlight(author: "Adam Scott" title: "JS Everywhere" content: "GraphQL is awesome") {
id
author
title
content
}
}
```Result:
```js
{
"data": {
"newHighlight": {
"id": "3",
"author": "Adam Scott",
"title": "JS Everywhere",
"content": "GraphQL is awesome"
}
}
}
```##### Mutation: Delete Record
```js
mutation {
deleteHighlight(id: "3") {
id
}
}
```Result:
```js
{
"data": {
"deleteHighlight": {
"id": "3"
}
}
}
``````js
```### Sources
[Get Started Building GraphQL APIs With Node](https://css-tricks.com/get-started-building-graphql-apis-with-node/)