Skip to content

Supporting Batch Resolvers in GraphQL-RubyΒ #5446

@rmosolgo

Description

@rmosolgo

There are some promising experiments out there (https://www.youtube.com/watch?v=bL2JCd1lo80, https://github.com/gmac/graphql-breadth-exec) about using "batch resolvers" to simplify data fetching for GraphQL and make GraphQL queries run faster.

In short, it involves changing the call signature of resolvers:

  - resolve(object, arguments, context)
  + resolve(objects, arguments, context) 

So that for a list selection like users { profilePic(size: LARGE) }, User.profilePic is resolved for the whole list of Users at once. Then, the GraphQL engine handles each object and continues executing.

This addresses the same problem as GraphQL::Dataloader and GraphQL::Batch, but in a totally different way. Both of the existing solutions run a query without any real knowledge of batching; batching is "slapped on" after the fact. But batch resolvers would recognize the need to handle similar objects in similar ways at the core of GraphQL execution.

Soon, I intend to add support for this flow in GraphQL-Ruby and I'm opening this issue in case anyone wants to discuss the idea.

Before I add this, I want to explore a few much-needed cleanups to the runtime code (eg #5389, #5422). I think paying down some tech debt will make it easier to add this feature ("make the change easy...").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions