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

io.smallrye.graphql.client.impl.typesafe.HeaderBuilder: throws RuntimeException when parameter name is not available even when a name is provided in @Header #1714

Closed
ftrossbach opened this issue Feb 3, 2023 · 3 comments
Assignees
Labels
bug Something isn't working Client This issue applies to the Client side

Comments

@ftrossbach
Copy link

We recently tried to instantiate a GraphQL Client in Wildfly 27.0.1 with the GraphQl Feature pack that looked like this:

@GraphQLClientApi(configKey = "my-api")
public interface MyApi {

	@Query
	MyObject object(@Header(name = "some-header") String someHeader, String someId);
}

This failed with a RuntimeException:

"Missing name information for arg0. You can either annotate all parameters 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."

We actually compiled the app without the -parameters, so changing this worked around the error. But I think it should never have been thrown as the parameter name from the byte code is only required as a fallback when there is no name provided in @Header.

Expected behaviour: missing parameter name in the byte code should not fail in HeaderBuilder when there is a name provided in @Header

@jmartisk
Copy link
Member

jmartisk commented Feb 3, 2023

It won't work without -parameters anyway, because it needs to know the someId parameter's name, no?
I'd say -parameters is required in 99% cases, so it doesn't make a lot of sense trying to make the 1% work.

@t1
Copy link
Collaborator

t1 commented Feb 3, 2023

-parameters is definitively the better option. But if you need only header parameters or you can't (for whatever reason) compile with -parameters, you'd have to annotate the header parameter, even though it's never used as you already have the @Header annotation!

I'll take a look.

@t1 t1 self-assigned this Feb 3, 2023
@t1 t1 added bug Something isn't working Client This issue applies to the Client side labels Feb 3, 2023
t1 added a commit to t1/smallrye-graphql that referenced this issue Feb 4, 2023
t1 added a commit to t1/smallrye-graphql that referenced this issue Feb 4, 2023
t1 added a commit to t1/smallrye-graphql that referenced this issue Feb 4, 2023
jmartisk pushed a commit that referenced this issue Feb 6, 2023
jmartisk pushed a commit that referenced this issue Feb 6, 2023
@jmartisk
Copy link
Member

jmartisk commented Feb 6, 2023

Thanks @t1 for resolving this. Note that in the future we want to switch from reflective calls to scanning the application's Jandex index, so -parameters won't be necessary at all then. But it's not something that will be resolved very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Client This issue applies to the Client side
Projects
None yet
Development

No branches or pull requests

3 participants