1
0
mirror of https://github.com/actix/examples synced 2024-11-25 07:12:42 +01:00
examples/graphql/juniper
Altug Sahin 8186a8cfea
fix broken links (#441)
Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
Co-authored-by: Altug Sahin <altugsahin@gmail.com>
Co-authored-by: Rob Ede <robjtede@icloud.com>
2021-10-06 22:28:53 +01:00
..
src Upgrade juniper to 0.15 (#423) 2021-04-26 20:32:32 +09:00
Cargo.toml Upgrade juniper to 0.15 (#423) 2021-04-26 20:32:32 +09:00
README.md fix broken links (#441) 2021-10-06 22:28:53 +01:00

Juniper

Juniper integration for Actix web. If you want more advanced example, see also the juniper-advanced example.

Usage

server

cd graphql/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

Query example:

{
  human(id: "1234") {
    name
    appearsIn
    homePlanet
  }
}

Result:

{
  "data": {
    "human": {
      "name": "Luke",
      "appearsIn": [
        "NEW_HOPE"
      ],
      "homePlanet": "Mars"
    }
  }
}

Mutation example:

mutation {
  createHuman(newHuman: {name: "Fresh Kid Ice", appearsIn: EMPIRE, homePlanet: "earth"}) {
    id
    name
    appearsIn
    homePlanet
  }
}

Result:

{
  "data": {
    "createHuman": {
      "id": "1234",
      "name": "Fresh Kid Ice",
      "appearsIn": [
        "EMPIRE"
      ],
      "homePlanet": "earth"
    }
  }
}