-
-
Save sherl0cks/2798af5960ff21395998e3386dd35045 to your computer and use it in GitHub Desktop.
[ | |
"com.acme.myapp.MyCoolGraphQlApi" | |
] |
package com.acme.myapp; | |
import io.quarkus.runtime.annotations.RegisterForReflection | |
@RegisterForReflection( | |
targets = [ | |
io.smallrye.graphql.client.typesafe.api.GraphQlClientApi::class, | |
io.smallrye.graphql.client.typesafe.api.GraphQlClientBuilder::class, | |
io.smallrye.graphql.client.typesafe.api.GraphQlClientHeader::class, | |
io.smallrye.graphql.client.typesafe.impl.GraphQlClientBuilderImpl::class, | |
io.smallrye.graphql.client.typesafe.impl.reflection.ConstructionInfo::class, | |
io.smallrye.graphql.client.typesafe.impl.reflection.FieldInfo::class, | |
io.smallrye.graphql.client.typesafe.impl.reflection.MethodInfo::class, | |
io.smallrye.graphql.client.typesafe.impl.reflection.ParameterInfo::class, | |
io.smallrye.graphql.client.typesafe.impl.reflection.TypeInfo::class, | |
javax.json.Json::class, | |
javax.json.JsonBuilderFactory::class, | |
javax.json.JsonObject::class, | |
javax.json.JsonObjectBuilder::class, | |
javax.json.JsonReaderFactory::class, | |
javax.json.JsonValue::class | |
] | |
) | |
class GraalReflectionConfig {} |
package com.acme.myapp | |
import io.quarkus.runtime.annotations.RegisterForReflection | |
import io.smallrye.graphql.client.typesafe.api.GraphQlClientApi | |
import io.smallrye.graphql.client.typesafe.api.GraphQlClientBuilder | |
import io.smallrye.graphql.client.typesafe.api.GraphQlClientHeader | |
import javax.enterprise.context.ApplicationScoped | |
import javax.enterprise.inject.Produces | |
@GraphQlClientApi(endpoint = "https://api.something.com/graphql") | |
interface MyCoolGraphQlApi { | |
fun queryName(request: List<RequestItem>): Response | |
} | |
// Do not forget this annotation! | |
@RegisterForReflection | |
data class RequestItem(var x: Double, var y: Double) | |
/* | |
I did not spend time trying to get Annotation Scanning working so I'm using this simple CDI producer. | |
*/ | |
@ApplicationScoped | |
class MyCoolGraphQlApiProducer { | |
@Produces | |
fun myCoolGraphQlApiClient(): MyCoolGraphQlApi = GraphQlClientBuilder | |
.newBuilder() | |
.header(GraphQlClientHeader("Authorization", "Bearer tokenDetails")) | |
.build(MyCoolGraphQlApi::class.java) | |
} |
<dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>io.quarkus</groupId> | |
<artifactId>quarkus-bom</artifactId> | |
<version>1.5.0.Final</version> | |
<type>pom</type> | |
<scope>import</scope> | |
</dependency> | |
<dependency> | |
<groupId>io.smallrye</groupId> | |
<artifactId>smallrye-parent</artifactId> | |
<version>18</version> | |
<type>pom</type> | |
<scope>import</scope> | |
</dependency> | |
</dependencies> | |
</dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>io.quarkus</groupId> | |
<artifactId>quarkus-rest-client</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>io.smallrye</groupId> | |
<artifactId>smallrye-graphql-client</artifactId> | |
<version>1.0.3</version> | |
</dependency> | |
<dependency> | |
<groupId>jakarta.json</groupId> | |
<artifactId>jakarta.json-api</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.glassfish</groupId> | |
<artifactId>jakarta.json</artifactId> | |
</dependency> | |
</dependencies> |
{ | |
"resources": [ | |
{ | |
"pattern": "META-INF/services/javax.enterprise.inject.spi.Extension" | |
}, | |
{ | |
"pattern": "META-INF/services/io.smallrye.graphql.client.typesafe.api.GraphQlClientBuilder" | |
} | |
] | |
} |
I believe this was discussed in chat @phillip-kruger, but I forgot about it and hit it with a new module I wrote using the graphql client. There is a requirement for the rest client extension, else the graphql client fails at runtime in native mode with Exception in thread "Lambda Thread" java.util.ServiceConfigurationError: io.smallrye.graphql.client.typesafe.api.GraphQlClientBuilder: Provider io.smallrye.graphql.client.typesafe.impl.GraphQlClientBuilderImpl not found
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
Yea, at this point our smallrye client just use rest client as a transport protocol. We still need to do some work there.
From end users perspective, transport really doesn’t matter so long as the transitive dependencies “just work.” In this case they did not, although I must admit that is one of the more confusing issues I’ve hit in graal native.
Awesome !! Thanks for this