-
Notifications
You must be signed in to change notification settings - Fork 918
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
Provide a way to customize GraphQL ExecutionId #4877
Provide a way to customize GraphQL ExecutionId #4877
Conversation
ExecutionIdGenerator
graphql/src/main/java/com/linecorp/armeria/server/graphql/ExecutionIdGenerator.java
Outdated
Show resolved
Hide resolved
graphql/src/test/java/com/linecorp/armeria/server/graphql/ExecutionIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
graphql/src/test/java/com/linecorp/armeria/server/graphql/ExecutionIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
e51020a
to
f71b3fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @tomatophobia! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments but basically looks good to me 👍 Thanks @tomatophobia ! 🙇 👍 🙇
graphql/src/main/java/com/linecorp/armeria/server/graphql/ExecutionIdGenerator.java
Outdated
Show resolved
Hide resolved
graphql/src/main/java/com/linecorp/armeria/server/graphql/ExecutionIdGenerator.java
Outdated
Show resolved
Hide resolved
graphql/src/main/java/com/linecorp/armeria/server/graphql/GraphqlServiceBuilder.java
Show resolved
Hide resolved
graphql/src/test/java/com/linecorp/armeria/server/graphql/ExecutionIdGeneratorTest.java
Outdated
Show resolved
Hide resolved
graphql/src/test/java/com/linecorp/armeria/server/graphql/ExecutionIdGeneratorTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once @jrhee17's comments are addressed.
Thanks!
2798ea9
to
55c7db7
Compare
graphql/src/main/java/com/linecorp/armeria/server/graphql/ExecutionIdGenerator.java
Show resolved
Hide resolved
graphql/src/main/java/com/linecorp/armeria/server/graphql/ExecutionIdGenerator.java
Outdated
Show resolved
Hide resolved
…utionIdGenerator.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @tomatophobia! ❤️
Motivation: This PR fixes `shadedTest` task to run with JUnit 5 and the bugs that weren't caught by CI builds because of the aforementioned bug. - `shadedTest`: `shadedTest` was configured to run test suites with JUnit 4. It caused CI builds to pass successfully, although they failed with `gradle test` when I run locally. While upgrading the Gradle version to 8, we had to use JVM test suites to use both JUnit and TestNG. In Gradle 8, `Test` didn't allow overring test frameworks. For that reason, `test` was migrated to test suites but `shadedTest` hasn't changed. - `RequestLog.resposneCause()`: Recently, I've encountered the following test failure repeatedly when I was running tests locally. ```java GrpcClientTest > errorNoMessage() FAILED java.lang.AssertionError: Expecting actual not to be null at com.linecorp.armeria.client.grpc.GrpcClientTest.lambda$errorNoMessage$44(GrpcClientTest.java:1639) at com.linecorp.armeria.client.grpc.GrpcClientTest.checkRequestLogError(GrpcClientTest.java:1863) at com.linecorp.armeria.client.grpc.GrpcClientTest.errorNoMessage(GrpcClientTest.java:1634) ``` That regression was caused by the change in #3904 that added `responseCause(Throwable)` and migrated `RpcResponse.cause()` to use the new API. https://github.com/line/armeria/pull/3904/files#diff-91096a8a0f87541eb2debf804754395c3000432ccc7af9167fd99d93e4241628 Since `RequestLog.responseCause(Throwable)` does not allow setting an exception if an HTTP response has ended, `RpcResponse.cause()`, produced after the HTTP response ended, wasn't recode to `RequestLog`. - `RequestLog.whenComplete()`: There is a case where `RequestLog.whenComplete()` is never complete when `RequestLog.whenComplete()` and `RequestLogBuilder.endResponse()` are invoked simultaneously. - GraphQL's `ExcutionId`: An `ExcutionIdGenerator` can be set to `GraphQL` while building a service. But the obsolete `ExcutionId` set to `ExecutionInput` wasn't removed. #4877 - `%3F`: - `RequestTarget` is fixed not to decode `%3F` into `?` in a path component but some tests weren't fixed. #4907 - Test Java version: `-PtestJavaVersion` wasn't properly set to non-`test` tasks such as `shadedTest`, `testNG`, `testStreaming`, and so on. Note: The regression has not yet been released, so there is no impact on users. Modifications: - Migrated `shadedTest` to JVM test suits to run tests with JUnit 5. - Fixed broken tests caused by #4907 - Directly set `RpcResponse.cause()` to `responseCause` if it is null - Read `flags` within `lock` before removing satisfied futures in `DefaultRequestLog` Result: Make CI builds run all tests
Motivation:
ExecutionId
is not explicitly set for a query in GraphQL-Java, a defaultExecutionId
is generated usingUUID.randomUUID()
. However, this default approach has drawbacks. To address these limitations, this PR introduces the ability for users to customize the generation ofExecutionId
.Modifications:
ExecutionIdGenerator
to enable customization of the execution ID generation mechanism using theServiceRequestContext
, query, and operation name.of()
method in theExecutionIdGenerator
interface provides a default implementation that automatically assigns the execution ID as the ID of theServiceRequestContext
, allowing for convenient generation of execution IDs.executionIdGenerator()
, is introduced in theGraphqlServiceBuilder
, which enables users to inject a customizedExecutionIdGenerator
instance into the builder.Result:
ExecutionId
#4867.ExecutionId
.ServiceRequestContext
as theExecutionID
.