Skip to content

How does graphql know which resolvers to use? #1100

Answered by ilslv
twiclo asked this question in Q&A
Discussion options

You must be logged in to vote

@twiclo juniper only calls resolvers, when they are actually requested. So if you query looks something like:

query {
    ticket(id: 3) {
        ticketId
    }
}

You don't need to execute Ticket::updates() in that case.

but I don't see how something like Ticket::updates() ever gets called.

To see updates you have to request it explicitly:

query {
    ticket(id: 3) {
        ticketId
        updates
    }
}

so then how is this working?

So with GraphQL object this is pretty easy. Macros generate GraphQLValue/GraphQLValueAsync impls, where you have a simple match:

// Very simplified, just to give an idea
impl GraphQLValueAsync for Ticket {
    fn resolve_field_async(&self, field: &str)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ilslv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants