1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00
examples/juniper/README.md

72 lines
949 B
Markdown
Raw Normal View History

2019-12-07 18:59:35 +01:00
# Juniper
2019-12-07 18:59:35 +01:00
[Juniper](https://github.com/graphql-rust/juniper) integration for Actix web
## Usage
### server
```bash
2018-05-21 03:18:00 +02:00
cd examples/juniper
cargo run (or ``cargo watch -x run``)
# Started http server: 127.0.0.1:8080
```
### web client
[http://127.0.0.1:8080/graphiql](http://127.0.0.1:8080/graphiql)
2019-12-07 18:59:35 +01:00
_Query example:_
```graphql
{
human(id: "1234") {
name
appearsIn
homePlanet
}
}
```
_Result:_
```json
{
"data": {
"human": {
"name": "Luke",
"appearsIn": [
"NEW_HOPE"
],
"homePlanet": "Mars"
}
}
}
```
_Mutation example:_
```graphql
mutation {
createHuman(newHuman: {name: "Fresh Kid Ice", appearsIn: EMPIRE, homePlanet: "earth"}) {
id
name
appearsIn
homePlanet
}
}
```
_Result:_
```json
{
"data": {
"createHuman": {
"id": "1234",
"name": "Fresh Kid Ice",
"appearsIn": [
"EMPIRE"
],
"homePlanet": "earth"
}
}
}
```