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

Batching JoinMonster calls #493

Open
TuurDutoit opened this issue Feb 9, 2023 · 0 comments
Open

Batching JoinMonster calls #493

TuurDutoit opened this issue Feb 9, 2023 · 0 comments

Comments

@TuurDutoit
Copy link

Describe the problem you'd like to have solved

We have some GraphQL queries where the top-level field is resolved from a different source, but nested objects are resolved using Join Monster. For example:

query {
  courses {
    id
    title
    pool {
      id
      title
      views {
        id
        question
      }
    }
  }
}

In this case, we have a resolver on Query.courses that fetches data from a different API. Course.pool and Pool.views are using Join Monster to query our database (pools and views tables, respectively).
With this query, we run into an n+1 issue: as Query.courses returns a list of courses, and Course.pool calls Join Monster for each course, we're making a DB query for each course!

Describe the ideal solution

A solution that would allow us to batch the Join Monster calls, something like a DataLoader, would be very helpful.

Alternatives and current work-arounds

We tried using batchDelegateToSchema from graphql-tools, but had some problems to get it to work reliably.

Additional context

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

No branches or pull requests

2 participants