Replies: 1 comment
-
for completeness @samuelAndalon answered in #1845
|
Beta Was this translation helpful? Give feedback.
-
for completeness @samuelAndalon answered in #1845
|
Beta Was this translation helpful? Give feedback.
-
I'm seeking advice on utilizing Instrumentation and data loaders. I'm encountering an issue when using Instrumentation and data loaders together. The main scenario involves employing multiple data loaders in a data fetcher. However, the problem arises when attempting to use the dispatchIfNeeded(env) method without Instrumentation.
Based on the guidance provided in the Instrumentation DataLoader tutorial, it's clear that the
dispatchIfNeeded
method is crucial for leveraging multiple loading data loaders. To enable this, I've configured the batching execution strategy by modifying environment properties as follows:This configuration introduces a new DataLoaderLevelDispatchedInstrumentation bean into the GraphQL instance. However, once this is implemented, numerous requests are initiated towards the server involving data loaders and data fetchers. Unfortunately, these requests remain incomplete and time out without being subscribed.
To address this issue, I incorporated an additional instrumentation data loader, DataLoaderDispatcherInstrumentation, which appears to be the default choice. This addition resolved the problem and the system now operates as expected.
Nevertheless, I'm still uncertain about the reasons behind this success. Is this the appropriate setup for GraphQL? Why were the requests failing to execute with only the level dispatched instrumentation? Why was it necessary to include DataLoaderDispatcherInstrumentation?
Here's the relevant code snippet for context:
Setting up
Full query for data loaders:
In conclusion, I have a few questions:
Is it possible to employ multiple data loaders within a single data fetcher without utilizing dispatchIfNeeded(env) and Instrumentation?
Why is it mandatory to include both DataLoaderDispatcherInstrumentation and DataLoaderLevelDispatchedInstrumentation for requests and mutations to execute properly? Without the former, most requests fail to execute.
Can I use multiple data loaders in a single data fetcher without enabling global batching?
Is it advisable to simultaneously utilize DataLoaderDispatcherInstrumentation and DataLoaderLevelDispatchedInstrumentation?
I appreciate your insights and guidance. Thank you for your assistance. Have a great day!
Beta Was this translation helpful? Give feedback.
All reactions