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

feat: support directives with the union annotation #1424

Merged
merged 2 commits into from
Apr 19, 2022

Conversation

bherrmann2
Copy link
Contributor

@bherrmann2 bherrmann2 commented Apr 18, 2022

📝 Description

the @GraphQLUnion annotation does not support directives. This is to add support by allowing it to be a meta-annotation where you can create an annotation for your union that you then annotate with @GraphQLUnion and directives

// Defined in some other library
class SharedModel(val foo: String)

// Our code
class ServiceModel(val bar: String)

@SomeDirective
@GraphQLUnion(
    name = "CustomUnion",
    possibleTypes = [SharedModel::class, ServiceModel::class],
    description = "Return one or the other model"
)
annotation class CustomUnion

class Query {

    @CustomUnion
    fun getModel(): Any = ServiceModel("abc")
}

🔗 Related Issues

Copy link

@valentyn-arkho valentyn-arkho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job 👍

@samuelAndalon samuelAndalon merged commit cba605c into ExpediaGroup:master Apr 19, 2022
@bherrmann2 bherrmann2 deleted the meta-union-annotation branch April 19, 2022 19:00
@dariuszkuc dariuszkuc added changes: patch Changes require a patch version changes: minor Changes require a minor version and removed changes: patch Changes require a patch version labels Apr 26, 2022
samuelAndalon pushed a commit that referenced this pull request May 9, 2022
* feat: support directives with the union annotation

* CR comment
samuelAndalon added a commit that referenced this pull request May 9, 2022
* feat: support directives with the union annotation (#1424)

* feat: support directives with the union annotation

* CR comment

* fix: willAddGraphQLTypeToSchema needs annotations from field (#1437)

* feat: use withDirective

* feat: update tests

Co-authored-by: bherrmann2 <bherrmann@expedia.com>
Co-authored-by: samvazquez <samvazquez@expedia.com>
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this pull request Aug 5, 2022
* feat: support directives with the union annotation

* CR comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: minor Changes require a minor version
Development

Successfully merging this pull request may close these issues.

5 participants