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

Type-safe client: custom factory / supplier? #2262

Closed
jmini opened this issue Jan 29, 2025 · 10 comments
Closed

Type-safe client: custom factory / supplier? #2262

jmini opened this issue Jan 29, 2025 · 10 comments

Comments

@jmini
Copy link
Contributor

jmini commented Jan 29, 2025

I am still working with the client and the query defined here #2224 (comment)

I would like to test a modification in InlineFragmentImpl and I was wondering if I can do this from the outside (from my Java main or Quarkus app)

I have seen the part that creates the GraphQL query seems to be based on the concept of Factory / Supplier:

public interface InlineFragmentFactory extends Supplier<InlineFragment> {
}

But I couldn't find if I can register my own supplier or not.

@jmini
Copy link
Contributor Author

jmini commented Jan 29, 2025

Maybe what I wrote does not make sense InlineFragmentImpl seems to be used in the dynamic client.

I continue my investigation on how I can influence the query generation of the typesafe client

@jmini
Copy link
Contributor Author

jmini commented Jan 29, 2025

The logic seems to be in io.smallrye.graphql.client.impl.typesafe.QueryBuilder and this might be very difficult to customize…

@jmartisk
Copy link
Member

So what exactly do you need to customize about the inline fragment?

@jmini
Copy link
Contributor Author

jmini commented Jan 29, 2025

I have opened a PR to discuss my precise problem and requested change:
#2264

If you know how I can try this change in my quarkus-app and/or in my standalone java app (executed using Jbang) I would be really interested.

@jmini
Copy link
Contributor Author

jmini commented Jan 29, 2025

@jmartisk how realistic is for me to build a custom smallrye-graphql containing my fix and a custom quarkus build with the same fix. I fear it is almost impossible.


What I have is that if I build locally smallrye-graphql, the client works as expected.

Client model version:
unblu/gitlab-workitem-graphql-client@556ac6f

And this implementation:

io.smallrye:smallrye-graphql-client-implementation-vertx:2.12.2-SNAPSHOT

Containing my improvement discussed in #2264

So instead of using a 2.12.2-SNAPSHOT I could create a release somewhere (our company nexus or something) and use that version.


But then to have this running in Quarkus? What should I do?

I already tried some crazy things in the past to force quarkus to use a newer smallrye-graphql` version:
quarkusio/quarkus#43756 (comment)
(but I am not really sure it really ever worked)

As a work-around is there a way to tell Quarkus to not use the build-steps and do everything at runtime?


My only other idea to have this fixed ASAP is to abandon the type-safe client and to transform it into a dynamic client where I would control the query.

@jmartisk
Copy link
Member

You can simply build a custom snapshot of smallrye-graphql and then, in the application's pom, declare io.smallrye:smallrye-graphql-client-parent as a separate dependency with the version pointing at your snapshot. AFAIK that should override the version from Quarkus. You may need to put it before the io.quarkus:quarkus-smallrye-graphql-client so that it has more priority (I think)

@jmartisk
Copy link
Member

If it doesn't work, you can checkout the quarkus main branch, change the version of smallrye-graphql dependency in bom/application/pom.xml and build a snapshot of Quarkus that depends on your snapshot of smallrye-graphql. That works for sure.

@jmini
Copy link
Contributor Author

jmini commented Jan 30, 2025

Thank you for those input. I will give it a try

@jmini
Copy link
Contributor Author

jmini commented Jan 30, 2025

in the application's pom, declare io.smallrye:smallrye-graphql-client-parent as a separate dependency with the version pointing at your snapshot. AFAIK that should override the version from Quarkus.

I think this is a maven thing.

My release (the maven release process failed somewhere but the client jars were published and I could upload them to our company maven repo) is based on this tag:
https://github.com/unblu/smallrye-graphql/releases/tag/2.12.2-unblu-2

With Gradle I did this:

    //upgrade 'smallrye-graphql-*' projects.
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'io.smallrye' && details.requested.name.startsWith('smallrye-graphql') && details.requested.version == '2.12.1') {
                details.useTarget group: 'patched.unblu.io.smallrye', name: details.requested.name, version: '2.12.2-unblu-2'
                details.because 'To get the fix of https://github.com/smallrye/smallrye-graphql/pull/2264'
            }
        }
    }

And as far as I can tell the jars are correctly replaced by gradle.

@jmini
Copy link
Contributor Author

jmini commented Jan 30, 2025

Thank you very much for your help, I think we can close this issue that was more a discussion.

@jmini jmini closed this as completed Jan 30, 2025
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

No branches or pull requests

2 participants