Error generating query $null parameter
I'm using Quarkus 3.10.1 with SmallRye-GraphQL-Client library.
I have to fetch data from this query:
query($listaIdTitoli: [BigInteger]) { loadProvvigioniSuTitoli(listaIdTitoli: $listaIdTitoli){ id } }
But when Quarkus start print this generated query:
Query created: query loadProvvigioniSuTitoli($null: [BigInteger]) { loadProvvigioniSuTitoli(listaIdTitoli: $null) {id} }
Quarkus set $null insted of $listaIdTitoli
Here my interface definition:
@GraphQLClientApi(configKey = "p2l")
public interface P2LGraphQLClient {
/**
* Recupero delle provvigioni di secondo livello a partire da un idTitolo
* @param listaIdTitoli lista degli id dei titoli tecnici
* @return la lista delle provvigioni per titolo
*/
List<ProvvigioneTitolo> loadProvvigioniSuTitoli(@Name("listaIdTitoli") List<Long> listaIdTitoli);
}
Very strange, gonna look into it
@vitomanu96
I tried to reproduce the problem for Quarkus 3.10.1, but my query building works as intended:
Traced log:
Query created: query loadProvvigioniSuTitoli($listaIdTitoli: [BigInteger]) { loadProvvigioniSuTitoli(listaIdTitoli: $listaIdTitoli) {id} }
I tested the data like this:
//...
List<ProvvigioneTitolo> loadProvvigioniSuTitoli(@Name("listaIdTitoli") List<Long> listaIdTitoli);
//...
class ProvvigioneTitolo {
int id;
}
//...
Can you please create a whole reproducer and link it?
Very strange, gonna look into it
A solution that worked was removing the @Name annotation from the parameter on the interface definition and adding:
<arg>-parameters</arg> under <compileArgs> on the POM, if you're using maven-compiler-plugin. Like this for example:
<configuration>
<compilerArgs>
--other args that may be here
<arg>-parameters</arg> -- this is the arg to add
</compilerArgs>
</configuration>
Basically passing the parameters to the java compiler via maven, allowing access at runtime. When you remove the @ Name annotation this is a solution that is also on the logs, which says:
You can either annotate all parameteres with @Name, or compile your source code with the -parameters options, so the parameter names are compiled into the class file and available at runtime.
Oh yes, you are right, thank you @ErtiRakipaj :). With that said, this exact reproducer (with removed configuration) does not log out the given error message. So, I will create a PR with the fix in a few.
I understand now; the Java Reflection approach previously returned the parameter names as arg0, arg1, arg2,...
So the solution was to add 1) the @Name to add the alias (the arg# will still be there) or 2) the undermentioned configuration.
But with the newly implemented Jandex approach, all the parameter names are returned as null, null, null,... (without the configuration)
I have to say that using the -parameters argument generally is considered required for Quarkus applications. If you don't have it, there's a lot of other ways that your app can blow up. Generating a default name in this case, I guess I'm not strictly against it, but it shouldn't be used, because you have little control over the name then.