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

Graphql Quarkus properties not working #20494

Closed
robp94 opened this issue Oct 1, 2021 · 11 comments · Fixed by #20602
Closed

Graphql Quarkus properties not working #20494

robp94 opened this issue Oct 1, 2021 · 11 comments · Fixed by #20602
Labels
Milestone

Comments

@robp94
Copy link
Contributor

robp94 commented Oct 1, 2021

Describe the bug

Some Quarkus properties for graphql do not work, their smallrye/graphql version do work.

properties which do not work:

quarkus.smallrye-graphql.show-runtime-exception-message=org.acme.CustomRuntimeException
quarkus.smallrye-graphql.error-extension-fields=code,description,queryPath

Documentation: https://quarkus.io/version/main/guides/smallrye-graphql#quarkus-smallrye-graphql_quarkus.smallrye-graphql.show-runtime-exception-message

properties which work:

mp.graphql.showErrorMessage=org.acme.CustomRuntimeException
smallrye.graphql.errorExtensionFields=code,description,queryPath

Expected behavior

When running the query

query a{
  testCustomRuntimeException
}

There should be the message of the exception and the error code.

{
  "errors": [
    {
      "message": "Test CustomRuntimeException",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "testCustomRuntimeException"
      ],
      "extensions": {
        "code": "CustomRuntimeException"
      }
    }
  ],
  "data": {
    "testCustomRuntimeException": null
  }
}

Actual behavior

There is no error code and only the standard error message.

{
  "errors": [
    {
      "message": "System error",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "testCustomRuntimeException"
      ],
      "extensions": {
        "classification": "DataFetchingException"
      }
    }
  ],
  "data": {
    "testCustomRuntimeException": null
  }
}

How to Reproduce?

code-with-quarkus-exceptions.zip
Run the query from above and activate/deactivate the properties.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.3.Final

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

No response

Additional information

No response

@robp94 robp94 added the kind/bug Something isn't working label Oct 1, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 1, 2021

/cc @jmartisk, @phillip-kruger

@phillip-kruger
Copy link
Member

@radcortez
Copy link
Member

I'll have a look.

@radcortez
Copy link
Member

I believe the issue is that the interceptor needs to be placed in the runtime dependency.

@phillip-kruger
Copy link
Member

Hi @radcortez thanks for your investigation. Can you explain why ?

@radcortez
Copy link
Member

Because for runtime, the deployment dependencies are not available, meaning that the interceptor is not there, so no mapping is actually done.

In the extension code it works fine because we add our tests into the deployment module.

@phillip-kruger
Copy link
Member

phillip-kruger commented Oct 8, 2021

Thanks @radcortez , what I do not get is that some mappings are working... and others not. Can you help me understand that ?

@radcortez
Copy link
Member

Yes, I was looking into it again because of another issue and I believe it is because we are mixing build-time configuration with runtime configuration.

A build-time configuration only takes effect during the build and then it has no further effect during runtime. The SmallRyeGraphQLConfig configuration is mapped has being build-time (phase default in the @ConfigRoot annotation). Now, it seems that for instance quarkus.smallrye-graphql.show-runtime-exception-message, is not a build time configuration, but something that is read on every invocation (so effectively a runtime configuration): https://github.com/smallrye/smallrye-graphql/blob/261310802b7062f1ecbd86fc51d3ea2a512a09d8/server/implementation/src/main/java/io/smallrye/graphql/execution/error/ExceptionHandler.java#L40

So, the reason why I believe it works in some cases is when during build you access a configuration, the interceptor kicks in and provides the relocation and we record the value. When the configuration is only read during runtime, the interceptor is not there so no relocation is provided. Does this make sense?

@radcortez
Copy link
Member

What we need to do is so split SmallRyeGraphQLConfig and keep all the configuration that is build-time only there, and create a new class with the configuration that is only read at runtime. And if you have a configuration that is both build and runtime we need to split that as well.

@phillip-kruger
Copy link
Member

phillip-kruger commented Oct 8, 2021

OK thanks. I do not think the config in question (above) is a Runtime Config ? At least it does not have to be ? Maybe the source (linked above) can change ?

@radcortez
Copy link
Member

When I was looking into the code yesterday I noticed that in here:
https://github.com/smallrye/smallrye-graphql/blob/261310802b7062f1ecbd86fc51d3ea2a512a09d8/server/implementation-cdi/src/main/java/io/smallrye/graphql/cdi/config/MicroProfileConfig.java#L70-L79

The showList was being populated only on first access call and then cached. So maybe we need to look at it to figure out why is not being set at build time.

@quarkus-bot quarkus-bot bot added this to the 2.4 - main milestone Oct 11, 2021
@gsmet gsmet modified the milestones: 2.4.0.CR1, 2.3.1.Final Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants