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 mutiny CompositeException instead of custom ErrorCode #15271

Closed
Andro999b opened this issue Feb 23, 2021 · 14 comments · Fixed by #15895
Closed

GraphQL mutiny CompositeException instead of custom ErrorCode #15271

Andro999b opened this issue Feb 23, 2021 · 14 comments · Fixed by #15895
Assignees
Milestone

Comments

@Andro999b
Copy link
Contributor

Andro999b commented Feb 23, 2021

Describe the bug
When using mutiny api with smallrye-graphql its not allow you to use custom ErrorCode

Expected behavior
return custom error code in response

Actual behavior
always return io.smallrye.mutiny.CompositeException

      "extensions": {
        "exception": "io.smallrye.mutiny.CompositeException",
        "classification": "DataFetchingException",
        "code": "composite"
      }

Reproducer
https://drive.google.com/file/d/1VEHmO6_spF8-QhPsBTUvHIJESt3KiAkF/view?usp=sharing

Sample code

@ErrorCode("custom-error")
public class CustomException extends RuntimeException {}


@GraphQLApi
public class GreetingResource {

    @Query
    public Uni<String> hello() {
        return Uni.createFrom().failure(new CustomException());
    }
}

console output:

2021-02-23 17:01:07,416 ERROR [io.sma.graphql] (ForkJoinPool.commonPool-worker-15) SRGQL012000: Data Fetching Error: io.smallrye.mutiny.CompositeException: Multiple exceptions caught:
        [Exception 0] org.acme.CustomException
        [Exception 1] io.smallrye.graphql.execution.datafetcher.DataFetcherException
        at io.smallrye.mutiny.operators.UniOnItemOrFailureMap$1.onFailure(UniOnItemOrFailureMap.java:63)
        at io.smallrye.mutiny.operators.UniSerializedSubscriber.onFailure(UniSerializedSubscriber.java:101)
        at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownFailure.subscribing(UniCreateFromKnownFailure.java:24)

Environment (please complete the following information):

  • Output of uname -a or ver: Linux andrii-PC 5.4.0-65-generic Gizmo fixes and enhancements #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version: openjdk version "11.0.9" 2020-10-20
  • GraalVM version (if different from Java): OpenJDK Runtime Environment GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06)
  • Quarkus version or git rev: 1.12.0.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): maven 3.6.3 or gradle 6.5.1
@Andro999b Andro999b added the kind/bug Something isn't working label Feb 23, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 23, 2021

@Andro999b
Copy link
Contributor Author

Andro999b commented Feb 23, 2021

@phillip-kruger I think problem here in UniDataFetcher.invokeAndTransform. Inside transform section it throws wrapped errors. Because its actual retrow exception instead of flatMap it to failure reactive stream. Mutiny operator do wrap re trowed exception with CompositeException. I am sure UniDataFetcher need to be rewrited to not throw but map errors, cause its general rule for reactive code.

@phillip-kruger
Copy link
Member

Hi @Andro999b

Thanks, I'll look at this a.s.a.p

@phillip-kruger phillip-kruger self-assigned this Feb 23, 2021
@phillip-kruger
Copy link
Member

Do you perhaps have a small reproducer? This might already be fix. If you can test against master, give that a go

@Andro999b
Copy link
Contributor Author

Andro999b commented Feb 23, 2021

@phillip-kruger I have checked latest code in smallrey-graphql. And dont think that it fixed. Basically bug very simple to reproduce(also can send archive with repoducer). Just look at sample code that i left in description.

@gsmet
Copy link
Member

gsmet commented Feb 23, 2021

Always easier for us if you can prepare a small archive reproducing the issue. We have a lot on our plate :). Thanks!

@Andro999b
Copy link
Contributor Author

Andro999b commented Feb 23, 2021

Here is reproducer https://drive.google.com/file/d/1VEHmO6_spF8-QhPsBTUvHIJESt3KiAkF/view?usp=sharing
I think i maybe can fix it. I can try to do this tomorrow if you need help.

@phillip-kruger
Copy link
Member

Hi @Andro999b - Thanks for the reproducer. If you want to fix it please go ahead !! SmallRye GraphQL welcomes new contributors :)

@Andro999b
Copy link
Contributor Author

@phillip-kruger fix for this: smallrye/smallrye-graphql#653

@phillip-kruger
Copy link
Member

Awesome ! Thanks @Andro999b

@Andro999b
Copy link
Contributor Author

Please close ticket when it will be available in quarkus.

@jponge
Copy link
Member

jponge commented Mar 8, 2021

Late to the party, but the fix is good :-) (Mutiny does the right thing when it has to report a composite exception due to multiple failures)

@Andro999b
Copy link
Contributor Author

Any chance that fix will be included into quarkus 1.13 release?

@phillip-kruger
Copy link
Member

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants