-
Say I have this setup with actix_web:
When I request a ticket it calls to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@twiclo query {
ticket(id: 3) {
ticketId
}
} You don't need to execute
To see query {
ticket(id: 3) {
ticketId
updates
}
}
So with // Very simplified, just to give an idea
impl GraphQLValueAsync for Ticket {
fn resolve_field_async(&self, field: &str) -> BoxFuture<ExecutionResult> {
async {
match field {
"ticketId" => self.ticket_id().as_graphql_value(),
"updates" => self.updates().await?.as_graphql_value(),
_ => Err("unknown field")
}
}
.boxed_local()
}
}
With |
Beta Was this translation helpful? Give feedback.
@twiclo
juniper
only calls resolvers, when they are actually requested. So if you query looks something like:You don't need to execute
Ticket::updates()
in that case.To see
updates
you have to request it explicitly:So with
GraphQL
object this is pretty easy. Macros generateGraphQLValue
/GraphQLValueAsync
impls, where you have a simple match: