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

Added field fetching method for Expedia #3571

Merged
merged 2 commits into from May 17, 2024
Merged

Conversation

bbakerman
Copy link
Member

When we changed InstrumentationContext to no longer take a CF as an argument, the callback to beginFieldFetch can no long know about the value that was fetched.

Expedia for example used to this know if the value was a SYNC or ASYNC value for this dispatch code.

This adds a new method with a new context class that can be called back with the object that was fetched (it might not be complete if its a CF say)

The default implementation calls back to the old method so that we dont break any one. But should it? v22 is only a few days old - if v22.1 was also breaking for this - the impact would be low - no zero but very low

@bbakerman
Copy link
Member Author

This needs more tests, especially around the Chained code to ensure we capture that its working ok

@@ -496,6 +497,7 @@ Async.CombinedBuilder<FieldValueInfo> getAsyncFieldValueInfo(
Object fetchedObject = invokeDataFetcher(executionContext, parameters, fieldDef, dataFetchingEnvironment, dataFetcher);
executionContext.getDataLoaderDispatcherStrategy().fieldFetched(executionContext, parameters, dataFetcher, fetchedObject);
fetchCtx.onDispatched();
fetchCtx.onFetchedValue(fetchedObject);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context callback now gets the fetched value

@samuelAndalon
Copy link

samuelAndalon commented Apr 18, 2024

PR looks good to me, the Chained instrumentation looks ok, as is similar to the other hooks using custom InstrumentationContext.

as you mentioned the purpose of this PR is to expose the resolved value from the DataFetcher, if we know that returned is a CompletableFuture or a materialized object we would know when is the right time to dispatch data loaders.

More information about our custom data loader dispatch instrumentation:
https://opensource.expediagroup.com/graphql-kotlin/docs/server/data-loader/data-loader-instrumentation/#dispatching-by-synchronous-execution-exhaustion

is this instrumentation something that graphql-java would be interested in adopting ? if so, i can create a PR.

…tions to show new methods is called and it delegates ok as well via Legacy one
@bbakerman bbakerman changed the title WIP - Added field fetching method for Expedia Added field fetching method for Expedia Apr 19, 2024
@samuelAndalon
Copy link

was able to verify this PR and our custom data loader dispatching instrumentation is working again.
https://github.com/ExpediaGroup/graphql-kotlin/pull/1967/files#diff-91b3cc57cc4747d6d28834d98147dc7233b95a2a646d291e85f787aebf230bd1R128

@bbakerman @dondonz i was wondering, if possible, an official RC release, this will help build tools to resolve dependencies properly.

samuelAndalon added a commit to ExpediaGroup/graphql-kotlin that referenced this pull request May 6, 2024
### 📝 Description
waiting for an official release of this PR
graphql-java/graphql-java#3571

UPDATE:
next graphql-java update will be on July,
https://github.com/graphql-java/graphql-java/milestone/69

they helped us releasing from this branch 
graphql-java/graphql-java#3571

which will unblock us.

https://github.com/graphql-java/graphql-java/releases/tag/v22.0
@dondonz
Copy link
Member

dondonz commented May 14, 2024

@samuelAndalon Thanks for the feedback. We'll include this PR in a special release.

@bbakerman bbakerman added this pull request to the merge queue May 17, 2024
Merged via the queue into master with commit 11e9788 May 17, 2024
2 checks passed
@dondonz dondonz deleted the add-field-fetching-method branch May 21, 2024 05:59
@dondonz
Copy link
Member

dondonz commented May 21, 2024

Hi @samuelAndalon we've included this PR in today's v22.1 release. It should be landing in Maven very soon.

Here are the release notes: https://github.com/graphql-java/graphql-java/releases/tag/v22.1

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

Successfully merging this pull request may close these issues.

None yet

3 participants