[−][src]Attribute Macro async_graphql::Subscription
#[Subscription]
Define a GraphQL subscription
The field function is a synchronization function that performs filtering. When true is returned, the message is pushed to the client. The second parameter is the type of the field. Starting with the third parameter is one or more filtering conditions, The filter condition is the parameter of the field. The filter function should be synchronous.
Macro parameters
Attribute | description | Type | Optional |
---|---|---|---|
name | Object name | string | Y |
desc | Object description | string | Y |
Field parameters
Attribute | description | Type | Optional |
---|---|---|---|
name | Field name | string | Y |
desc | Field description | string | Y |
deprecation | Field deprecation reason | string | Y |
Field argument parameters
Attribute | description | Type | Optional |
---|---|---|---|
name | Argument name | string | Y |
desc | Argument description | string | Y |
default | Argument default value | string | Y |
validators | Input value validators | InputValueValidator | Y |
Examples
ⓘThis example is not tested
use async_graphql::*; #[Object] struct Event { value: i32, } struct SubscriptionRoot; #[Subscription] impl SubscriptionRoot { #[field] async fn value(&self, event: &Event, condition: i32) -> bool { // Push when value is greater than condition event.value > condition } }