-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from cybozu-go/improve-graphql
Improve GraphQL implementation
- Loading branch information
Showing
14 changed files
with
402 additions
and
286 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,102 @@ | ||
GraphQL API | ||
=========== | ||
|
||
Sabakan provides GraphQL API at `/graphql` HTTP endpoint. | ||
Sabakan provides [GraphQL][] API at `/graphql` HTTP endpoint. | ||
|
||
Schema | ||
------ | ||
|
||
See [gql/schema.graphql](../gql/schema.graphql). | ||
|
||
Playground | ||
---------- | ||
|
||
If [sabakan](sabakan.md) starts with `-enable-playground` command-line flag, | ||
it serves a web-based playground for GraphQL API at `/playground` HTTP endpoint. | ||
|
||
Example | ||
------- | ||
|
||
Searching machines matching the these conditions: | ||
|
||
* the machine has a label whose key is "datacenter" and value is "dc1". | ||
* the machine's current state is _healthy_. | ||
* the machine is not in rack 1. | ||
|
||
can be done with a GraphQL query and variables as follows: | ||
|
||
### Query | ||
|
||
``` | ||
query search($having: MachineParams = null, $notHaving: MachineParams = null) { | ||
searchMachines(having: $having, notHaving: $notHaving) { | ||
spec { | ||
serial | ||
labels { | ||
name | ||
value | ||
} | ||
ipv4 | ||
rack | ||
} | ||
status { | ||
state | ||
timestamp | ||
duration | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Variables | ||
|
||
```json | ||
{ | ||
"having": { | ||
"labels": [ | ||
{"name": "datacenter", "value": "dc1"} | ||
], | ||
"states": ["HEALTHY"] | ||
}, | ||
"notHaving": { | ||
"racks": [1] | ||
} | ||
} | ||
``` | ||
|
||
### Result | ||
|
||
```json | ||
{ | ||
"data": { | ||
"searchMachines": [ | ||
{ | ||
"spec": { | ||
"serial": "00000004", | ||
"labels": [ | ||
{ | ||
"name": "datacenter", | ||
"value": "dc1" | ||
}, | ||
{ | ||
"name": "product", | ||
"value": "vm" | ||
} | ||
], | ||
"ipv4": [ | ||
"10.0.0.104" | ||
], | ||
"rack": 0 | ||
}, | ||
"status": { | ||
"state": "HEALTHY", | ||
"timestamp": "2018-11-26T09:17:20Z", | ||
"duration": 21678.990289 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
[GraphQL]: https://graphql.org/ |
This file contains 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
Oops, something went wrong.