overblog/GraphQLBundle

Dataloader or Resolver Contexts & Parameters

LeoAdamek opened this issue · 0 comments

Q A
Bug report? no
Feature request?
BC Break report? no
RFC? no
Version/Branch 1.1.0

How can a data loader or Resolver be separated by the field its resolving in a query, and take in additional parameters.

For example say I have the following schema:

type Product {
   id: ID!
   active: Boolean!
   name: String!
}

type Order {
  id: ID!
  products(active: Boolean): [Product!]
}

type RootQuery {
  orders: [Order!]
}

schema {
   query: RootQuery!
}

And then the following query:

query getOrders { 
   orders {
    id
   
   activeProducts: products(active: true) { id, name }
   inactiveProducts: products(active: false) { id, name }
  }
}

How would I configure this so that two instances of a ProductResolver are created, one for the activeProducts field, one for the inactiveProducts field, each taking in the active parameter.

I've had a look through the documentation and the source but I can't figure it out, it seems like only one instance of a DataLoader or a Resolver is created regardless of how many different fields resolve it.

How do I do this?