rmosolgo / rmosolgo/graphql-ruby

Unexpected dataloader request/load behavior with multiple Sources

Open
#3,699 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
5.4k
Forks
1.4k
Avg merge
23h 19m
Merged PRs (30d)
28

Description

Describe the bug

A dataloader load for one source triggers db queries for pending requests for other sources as well.

Versions

graphql version: 1.12.16
rails (or other framework): rails 6.1.3.1

Steps to reproduce

If dataloader has pending requests for Source A,

dataloader.with(Sources::A).request(1)

and then receives a call to load for Source B,

dataloader.with(Sources::B).load(2)

it queries the db for both the Source B data and the Source A data.

Expected behavior

I expected this scenario to only query the db for Source B data, allowing me to queue up further requests for Source A before finally running its db query.

I'm not sure whether this is a bug or a misunderstanding on my part (and I apologize if that's the case).

Actual behavior

The load for Source B executing pending data requests for both sources, meaning if I wasn't done collecting all my Source A data requests, I end up making two trips to the Source A db table.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two-Source scenario with graphql 1.12.16 and Rails 6.1.3.1: queue a request for Sources::A, then load Sources::B, and observe which database queries run. Trace the dataloader request/load path and verify that loading Source B does not execute pending Source A requests until Source A is explicitly loaded.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, rails, ruby
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.