1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00
examples/graphql/juniper
2022-02-18 02:44:02 +00:00
..
src fmt 2022-02-18 02:44:02 +00:00
Cargo.toml update juniper example 2022-02-17 20:37:51 +00:00
README.md update async-graphql example 2022-02-17 21:29:55 +00:00

GraphQL using 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

Web Client

Go to http://localhost:8080/graphiql in your browser.

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"
    }
  }
}