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

Graphql Use new async handleException method #3090

Merged
merged 11 commits into from
Jan 12, 2024
Merged

Conversation

lbloder
Copy link
Collaborator

@lbloder lbloder commented Dec 11, 2023

📜 Description

Use new async handleException method for compatibility with newer Graphql-Java Versions.
In order to stay compatible with both older and newer verions, the @Override annotation of the deprecated onException method has been removed. onException now calls the handleException implementation. The min supported GraphQL Version is 17, which introduced the new async method and the graphQLContext that our implementation relies on.

💡 Motivation and Context

Starting with graphql-java v21, implementing the handleException method is required and the deprecated method onException has been removed from the DataFetcherExceptionHandler interface.

Fixes #3017

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

lbloder and others added 2 commits December 4, 2023 15:43
Copy link
Contributor

github-actions bot commented Dec 11, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 399.20 ms 448.00 ms 48.80 ms
Size 1.70 MiB 2.27 MiB 582.26 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4e29063 384.14 ms 447.74 ms 63.60 ms
d429384 397.33 ms 457.69 ms 60.36 ms
93a76ca 397.30 ms 455.16 ms 57.87 ms
937879e 400.98 ms 482.84 ms 81.86 ms
606074f 384.90 ms 456.90 ms 72.00 ms
3d8bd2b 379.45 ms 450.36 ms 70.90 ms
2fad834 390.07 ms 470.80 ms 80.73 ms
b172d4e 352.92 ms 446.50 ms 93.58 ms
c3f503e 360.41 ms 434.67 ms 74.27 ms
93a76ca 378.48 ms 451.78 ms 73.30 ms

App size

Revision Plain With Sentry Diff
4e29063 1.72 MiB 2.29 MiB 578.38 KiB
d429384 1.72 MiB 2.27 MiB 558.42 KiB
93a76ca 1.72 MiB 2.29 MiB 576.75 KiB
937879e 1.72 MiB 2.27 MiB 558.42 KiB
606074f 1.72 MiB 2.27 MiB 558.30 KiB
3d8bd2b 1.72 MiB 2.29 MiB 577.53 KiB
2fad834 1.72 MiB 2.29 MiB 577.53 KiB
b172d4e 1.72 MiB 2.29 MiB 578.09 KiB
c3f503e 1.72 MiB 2.29 MiB 577.04 KiB
93a76ca 1.72 MiB 2.29 MiB 576.75 KiB

Previous results on branch: graphql-exception-handler

Startup times

Revision Plain With Sentry Diff
0417432 422.68 ms 477.78 ms 55.10 ms
b936993 392.46 ms 473.14 ms 80.69 ms
8dd20e3 401.54 ms 542.06 ms 140.52 ms
83cb64c 297.31 ms 339.06 ms 41.75 ms
351ac25 397.96 ms 459.00 ms 61.04 ms
5ac1966 396.50 ms 422.35 ms 25.85 ms

App size

Revision Plain With Sentry Diff
0417432 1.72 MiB 2.27 MiB 558.56 KiB
b936993 1.72 MiB 2.27 MiB 554.95 KiB
8dd20e3 1.72 MiB 2.27 MiB 558.21 KiB
83cb64c 1.72 MiB 2.27 MiB 554.95 KiB
351ac25 1.72 MiB 2.27 MiB 558.21 KiB
5ac1966 1.72 MiB 2.27 MiB 554.95 KiB

handleException(handlerParameters);

if (futureResult != null) {
return futureResult.join();
Copy link
Member

Choose a reason for hiding this comment

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

We should use .get() here combined with try/catch as well?

try {
return futureResult.get();
} catch (InterruptedException | ExecutionException e) {
return CompletableFuture.completedFuture((DataFetcherExceptionHandlerResult) null).join();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return CompletableFuture.completedFuture((DataFetcherExceptionHandlerResult) null).join();
return null;

handleException(handlerParameters);

if (futureResult == null) {
return CompletableFuture.completedFuture((DataFetcherExceptionHandlerResult) null).join();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return CompletableFuture.completedFuture((DataFetcherExceptionHandlerResult) null).join();
return null;

if (futureResult != null) {
return futureResult.join();
} else {
return CompletableFuture.completedFuture((DataFetcherExceptionHandlerResult) null).join();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return CompletableFuture.completedFuture((DataFetcherExceptionHandlerResult) null).join();
return null;

}

@SuppressWarnings("deprecation")
public @Nullable DataFetcherExceptionHandlerResult onException(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@adinauer this was not nullable before. Should we rather return an empty DataFetcherExceptionHandlerResult ?

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah I missed that, let's keep it @NotNull

@adinauer adinauer merged commit 3ae645b into main Jan 12, 2024
20 checks passed
@adinauer adinauer deleted the graphql-exception-handler branch January 12, 2024 08:09
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.

Implement handleException method in SentryGenericDataFetcherExceptionHandler
3 participants