mirror of
https://github.com/actix/examples
synced 2025-06-27 01:27:43 +02:00
Restructure folders (#411)
This commit is contained in:
committed by
GitHub
parent
9db98162b2
commit
c3407627d0
74
graphql/juniper/README.md
Normal file
74
graphql/juniper/README.md
Normal file
@ -0,0 +1,74 @@
|
||||
# Juniper
|
||||
|
||||
[Juniper](https://github.com/graphql-rust/juniper) integration for Actix web.
|
||||
If you want more advanced example, see also the [juniper-advanced example].
|
||||
|
||||
[juniper-advanced example]: https://github.com/actix/examples/tree/master/juniper-advanced
|
||||
|
||||
## Usage
|
||||
|
||||
### server
|
||||
|
||||
```bash
|
||||
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)
|
||||
|
||||
_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"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
Reference in New Issue
Block a user