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 client: "endpoint" parameter in "@GraphQLClientApi" has precedence over "application.properties" #44334

Closed
jmini opened this issue Nov 6, 2024 · 16 comments · Fixed by #44441

Comments

@jmini
Copy link
Contributor

jmini commented Nov 6, 2024

From comment #44293 (comment):

When testing the GraphQL client I discovered that the endpoint defined in the annotation:

@GraphQLClientApi(configKey = "gitlab", endpoint = "https://gitlab.com/api/graphql")

Has precedence over what is defined in the application properties:

quarkus.smallrye-graphql-client.gitlab.url=https://gitlab.example.org/api/graphql

Example commit to "move" the config property:
jmini/gitlab-experiments@a79a36c

According to @jmartisk it should be the other way around.


Note that the settings made in TypesafeGraphQLClientBuilder wins over what is defined in the application properties, but I think that this is correct:

TypesafeGraphQLClientBuilder.newBuilder()
                .endpoint("https://gitlab.example.org/api/graphql")
                .header("Authorization", "Bearer " + gitlabToken)
                .build(WorkitemClientApi.class);
Copy link

quarkus-bot bot commented Nov 6, 2024

/cc @jmartisk (graphql), @phillip-kruger (graphql)

@jmini
Copy link
Contributor Author

jmini commented Nov 6, 2024

@jmartisk If you point me to the location of the integration test in quarkus, I could try to add a unit test to validate my observations (and if the expectation is that "application.properties" should win, then this test should fail)

@jmartisk
Copy link
Contributor

jmartisk commented Nov 6, 2024

@jmini a good similar test to get started from would be, for example, https://github.com/quarkusio/quarkus/blob/main/extensions/smallrye-graphql-client/deployment/src/test/java/io/quarkus/smallrye/graphql/client/deployment/DynamicGraphQLClientInjectionWithQuarkusConfigTest.java - you will just need to make it use a different Client API interface - one that specifies a hardcoded URL

jmini added a commit to jmini/quarkus that referenced this issue Nov 6, 2024
jmini added a commit to jmini/quarkus that referenced this issue Nov 6, 2024
@jmini
Copy link
Contributor Author

jmini commented Nov 6, 2024

@jmartisk I think my test pushed here:
jmini@27845af
Validates that endpoint in @GraphQLClientApi has precedence over application.properties

Test result from the CI

Error:  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 61.92 s <<< FAILURE! -- in io.quarkus.smallrye.graphql.client.deployment.TypesafeGraphQLClientInjectionWithQuarkusConfigTest
Error:  io.quarkus.smallrye.graphql.client.deployment.TypesafeGraphQLClientInjectionWithQuarkusConfigTest.performQueryWithSecondClient -- Time elapsed: 60.13 s <<< ERROR!
java.lang.RuntimeException: Request failed
	at io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientProxy.postSync(VertxTypesafeGraphQLClientProxy.java:464)
	at io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientProxy.executeSingleResultOperationOverHttpSync(VertxTypesafeGraphQLClientProxy.java:172)
	at io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientProxy.invoke(VertxTypesafeGraphQLClientProxy.java:160)
	at io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientBuilder.invoke(VertxTypesafeGraphQLClientBuilder.java:241)
	at io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientBuilder.lambda$build$0(VertxTypesafeGraphQLClientBuilder.java:201)
	at jdk.proxy41/jdk.proxy41.$Proxy429.people(Unknown Source)
	at io.quarkus.smallrye.graphql.client.deployment.model.Testing2GraphQLClientApi_DJ2qC3VItixwTS-3X6K06sLUjWg_Synthetic_ClientProxy.people(Unknown Source)
	at io.quarkus.smallrye.graphql.client.deployment.TypesafeGraphQLClientInjectionWithQuarkusConfigTest.performQueryWithSecondClient(TypesafeGraphQLClientInjectionWithQuarkusConfigTest.java:66)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at io.quarkus.test.QuarkusUnitTest.runExtensionMethod(QuarkusUnitTest.java:513)
	at io.quarkus.test.QuarkusUnitTest.interceptTestMethod(QuarkusUnitTest.java:427)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.util.concurrent.ExecutionException: io.netty.channel.ConnectTimeoutException: connection timed out after 60000 ms: graphql.acme.org/64.98.135.60:443
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
	at io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientProxy.postSync(VertxTypesafeGraphQLClientProxy.java:462)
	... 12 more
Caused by: io.netty.channel.ConnectTimeoutException: connection timed out after 60000 ms: graphql.acme.org/64.98.135.60:443
	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:263)
	at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
	at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:153)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:840)

[INFO] 
[INFO] Results:
[INFO] 
Error:  Errors: 
Error:  io.quarkus.smallrye.graphql.client.deployment.TypesafeGraphQLClientInjectionWithQuarkusConfigTest.performQueryWithSecondClient
Error:    Run 1: TypesafeGraphQLClientInjectionWithQuarkusConfigTest.performQueryWithSecondClient:66 » Runtime Request failed
Error:    Run 2: TypesafeGraphQLClientInjectionWithQuarkusConfigTest.performQueryWithSecondClient:66 » Runtime Request failed
Error:    Run 3: TypesafeGraphQLClientInjectionWithQuarkusConfigTest.performQueryWithSecondClient:66 » Runtime Request failed
Error:    Run 4: TypesafeGraphQLClientInjectionWithQuarkusConfigTest.performQueryWithSecondClient:66 » Runtime Request failed
[INFO] 
[INFO] 
Error:  Tests run: 41, Failures: 0, Errors: 1, Skipped: 1

Source: https://github.com/jmini/quarkus/actions/runs/11701187729/job/32587425640

Any idea what I should investigate for the fix?

Maybe the place where the configs are merged?

@jmartisk
Copy link
Contributor

jmartisk commented Nov 6, 2024

Thanks @jmini !! @mskacelik has already started looking into it. It's a bit tricky, but I think we will figure it out

@mskacelik
Copy link
Contributor

@jmini
Copy link
Contributor Author

jmini commented Nov 6, 2024

Then maybe we can integrate my test after the SmallRye GraphQL client with the fix has been released and updated in Quarkus.

@jmartisk
Copy link
Contributor

Fixed via smallrye/smallrye-graphql#2223, so it will be included in Quarkus 3.17 (probably)

@jmini do you want to submit a test yourself (you'd need to change your commit with the test to add a new test instead of changing an existing one)? The fix is not in Quarkus yet, but if you want to do it now, I can start a new Quarkus branch that will serve for capturing changes related to SmallRye GraphQL 2.12, and you could send a PR to that branch. Or we can tell @mskacelik to take care of it, whatever you prefer.

@jmini
Copy link
Contributor Author

jmini commented Nov 12, 2024

Don't you need a release of SmallRye GraphQL 2.12 first?

I am happy to contribute my test, I will split the test as required and open a draft MR because it is easier to discuss on code changes. (the draft PR can remain open until there is a SmallRye release)

From my side the release and the quarkus update is not urgent, the work-around of removing the endpoint attribute in the annotation (as I did in jmini/gitlab-experiments@a79a36c) is really not a blocker for me.

@jmartisk
Copy link
Contributor

jmartisk commented Nov 12, 2024

We usually do it the way that I maintain a custom branch of Quarkus that captures the changes related to the next smallrye-graphql upgrade, and the branch depends on a snapshot of the upcoming release version.

But you can as well just send a draft PR straight to Quarkus (without actually changing the dependency version, so the test will just fail for now) and I will make sure to merge it after the smallrye-graphql upgrade. That will most likely be easier in this case

@jmini
Copy link
Contributor Author

jmini commented Nov 12, 2024

and the branch depends on a snapshot of the upcoming release version.

If you already created that branch, I can target this with my PR and then the test should be green.

@jmartisk
Copy link
Contributor

That won't work like this OOTB because the Quarkus CI doesn't know how to build a snapshot of smallrye-graphql, and we don't deploy snapshots into public Maven repositories.
Let's keep it simple and just send a draft PR to Quarkus? If you locally develop it against a smallrye-graphql snapshot in a way that the test passes, it will be easy for me to simply merge it after the upgrade.

jmini added a commit to jmini/quarkus that referenced this issue Nov 12, 2024
jmini added a commit to jmini/quarkus that referenced this issue Nov 12, 2024
@jmini
Copy link
Contributor Author

jmini commented Nov 12, 2024

Let's keep it simple and just send a draft PR to Quarkus? If you locally develop it against a smallrye-graphql snapshot in a way that the test passes, it will be easy for me to simply merge it after the upgrade.

This was my first proposal. 😉

If you locally develop it against a smallrye-graphql snapshot in a way that the test passes, it will be easy for me to simply merge it after the upgrade.

I don't have that setup on my machine. But maybe you can try my branch on your machine locally. Otherwise we hope that the change in jmini/gitlab-experiments@a79a36c is good, but we will only be sure after the smallrye release.

@jmartisk
Copy link
Contributor

Ok I'll do a test run with jmini@26d61f6 and let you know

@jmartisk
Copy link
Contributor

Yeah it worked, just feel free to send a draft PR with jmini@26d61f6 and say in the description that it requires an upgrade SmallRye GraphQL 2.11.1 or 2.12.0, and I'll take care of it

@jmini
Copy link
Contributor Author

jmini commented Nov 12, 2024

See #44441

jmini added a commit to jmini/quarkus that referenced this issue Jan 7, 2025
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants