quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

smallrye-graphql-client - Typesafe mode - Erreur Nullability mismatch on variable #43385

Closed jeanphi-baconnais closed 1 month ago

jeanphi-baconnais commented 1 month ago

Describe the bug

Hello 👋 I would like to call the GitHub GraphQL API and execute this query

query myQuery($login: String!) {
    user(login: $login) {
      contributionsCollection {
        totalIssueContributions
        totalCommitContributions
        totalPullRequestContributions
        totalPullRequestReviewContributions
        totalRepositoryContributions
      }
    }
  }

You can test it on the GitHub GraphQL Explorer : https://docs.github.com/en/graphql/overview/explorer

To do this, I add the smallrye-graphql-client extension (version 2.8.6) and read these 2 pages : https://smallrye.io/smallrye-graphql/2.8.6/dynamic-client-usage/ and https://quarkus.io/guides/smallrye-graphql-client#logging

With the Typesafe method, I created an interface with this :

@GraphQLClientApi(configKey = "github-api")
@AuthorizationHeader(type = AuthorizationHeader.Type.BEARER)
public interface GitHubGraphQLClient {
    User user(String login);
}

and the call to my endpoint gives me this error

- Error{message=Nullability mismatch on variable $login and argument login (String / String!), locations=[{line=1, column=35}], path=[query user, user, login], extensions={code=variableMismatch, variableName=login, argumentName=login, typeName=String, errorMessage=Nullability mismatch}})

To be sure that my login pasted in my endoint, I hardcoded my login

   return gitHubGraphQLClient.user("jeanphi-baconnais");

I don't know why I had this message 🤔

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

Darwin Kernel Version 23.6.0 root:xnu-10063.141.2~1/RELEASE_X86_64 x86_64

Output of java -version

OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode)

Quarkus version or git rev

3.12.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)

Additional information

No response

quarkus-bot[bot] commented 1 month ago

/cc @Ladicek (smallrye), @jmartisk (graphql,smallrye), @phillip-kruger (graphql,smallrye), @radcortez (smallrye)

jmartisk commented 1 month ago

Could you try to change the client interface and mark the argument as non-null? Like this:

 User user(@org.eclipse.microprofile.graphql.NonNull String login);
jeanphi-baconnais commented 1 month ago

I tested this before creating the issue and the problem was there. But after restarting my app, I have another message from jackson. I have to check this part but it's seems to be good. Thanks for your quickly response @jmartisk

jeanphi-baconnais commented 1 month ago

After set my bean, it's ok, thanks @jmartisk . I close this issue !