2020-04-15 03:15:30 +00:00
# Actix-web
2020-05-09 21:56:45 +00:00
2020-09-01 05:47:22 +00:00
`Async-graphql-actix-web` provides an implementation of `actix_web::FromRequest` for `GQLRequest` . This is actually an abstraction around `QueryBuilder` and you can call `GQLRequest::into_inner` to convert it into a `QueryBuilder` .
2020-05-09 21:56:45 +00:00
2020-09-01 05:47:22 +00:00
`WSSubscription` is an Actor that supports WebSocket subscriptions.
2020-05-09 21:56:45 +00:00
## Request example
When you define your `actix_web::App` you need to pass in the Schema as data.
```rust
async fn index(
// Schema now accessible here
schema: web::Data< Schema > ,
gql_request: GQLRequest,
) -> web::Json< GQLResponse > {
web::Json(GQLResponse(gql_request.into_inner().execute(& schema).await))
}
```
## Subscription example
```rust
async fn index_ws(
schema: web::Data< Schema > ,
req: HttpRequest,
payload: web::Payload,
) -> Result< HttpResponse > {
ws::start_with_protocols(WSSubscription::new(& schema), & ["graphql-ws"], & req, payload)
}
```