graphql-java icon indicating copy to clipboard operation
graphql-java copied to clipboard

ExecutorInstrumentation doesn't resolve fetchers which invokes a data loader

Open vivekkothari opened this issue 2 years ago • 5 comments

Describe the bug

ExecutorInstrumentation doesn't resolve fetchers which invokes a data loader.

To Reproduce

Sample Schema:


type Query {

   account(id: String): Account

}

type Account {
  id: String!
  name: String!
  transactions: [Transaction!]
}

type Transaction {
  id: String!
  accountId: String!
  amount: numeric!
}

record Account(String id, String name) {}

  record Transaction(String id, String accountId, double amount) {}

  public static class AccountFetcher implements TrivialDataFetcher<Account> {

    @Override
    public Account get(DataFetchingEnvironment environment) throws Exception {
      return new Account("id", "name");
    }
  }

  public static class TransactionFetcher
      implements DataFetcher<CompletionStage<List<Transaction>>> {

    @Override
    public CompletionStage<List<Transaction>> get(DataFetchingEnvironment environment)
        throws Exception {
      Account account = environment.getSource();
      DataLoader<String, List<Transaction>> dataLoader =
          environment.getDataLoader("transactionsByAccountIdLoader");
      return dataLoader.load(account.id());
    }
  }

If I use ExecutorInstrumentation as an instrumentation, the properties of Account like id and name gets resolved correctly, but, transactions don't. I think what's happening is the framework is somehow not dispatching the dataloaders.

I know its a Beta class, but I really wanted to use it so that I can control and tweak the thread pool used by the library.

vivekkothari avatar Jun 16 '23 13:06 vivekkothari

Hello, this issue has been inactive for 60 days, so we're marking it as stale. If you would like to continue this discussion, please comment within the next 30 days or we'll close the issue.

github-actions[bot] avatar Nov 22 '23 00:11 github-actions[bot]

Any update on this?

vivekkothari avatar Nov 22 '23 14:11 vivekkothari

I have managed to make a reproduction here and I can confirm is is NOT working

See https://github.com/graphql-java/graphql-java/pull/3625

If I remove the async "fetch executor" in the test it works but with it in place it does not seem to dispatch and hence evercomplete

I have not as yet debugged deeply into why?

bbakerman avatar Jun 10 '24 04:06 bbakerman

Any update on this?

vivekkothari avatar Aug 12 '24 02:08 vivekkothari

Sorry no update -

The class is marked as

@Internal
@Beta
public class ExecutorInstrumentation extends SimplePerformantInstrumentation {

It was an experiement a long time ago and honestly its not a core part of the library - I would avoid it given it has problems

bbakerman avatar Aug 12 '24 03:08 bbakerman

Hello, this issue has been inactive for 60 days, so we're marking it as stale. If you would like to continue this discussion, please comment within the next 30 days or we'll close the issue.

github-actions[bot] avatar Jan 24 '25 00:01 github-actions[bot]

I think we should just remove the class - it does not work properly

bbakerman avatar Jan 29 '25 03:01 bbakerman