Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataloader or Resolver Contexts & Parameters #1164

Open
LeoAdamek opened this issue Mar 8, 2024 · 0 comments
Open

Dataloader or Resolver Contexts & Parameters #1164

LeoAdamek opened this issue Mar 8, 2024 · 0 comments

Comments

@LeoAdamek
Copy link

LeoAdamek commented Mar 8, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant