Skip to content

Backport GraphQLUnion to 4.x.x #1234

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

Merged
merged 1 commit into from
Aug 12, 2021
Merged

Conversation

smyrick
Copy link
Contributor

@smyrick smyrick commented Aug 4, 2021

📝 Description

Since the schema can be generated from code you can use existing Kotlin classes from common libraries to define shared models. However if you want to declare an object defined in the library as implementing some new interface or union in your service it is not possible, since we can't modify the class definition to add Kotlin code to it.

These changes would allow us to use Any as the return type in the schema but then, through annotations, modify the schema return type to match the new class we want to use.

For example in an SDL-First world you could have this Kotlin class defined in some library

data class SharedModel(val foo: String)

And then write your schema as the following

interface CustomServiceInterface {
  foo: String!
}

type SharedModel implements CustomServiceInterface {
  foo: String!
}

type CustomServiceModel implements CustomServiceInterface {
  foo: String!
  bar: String!
}

union CustomServiceUnion = SharedModel | CustomServiceModel

But this is not currently possible in the full code-generation approach

🔗 Related Issues

PR into master branch: #1194

@smyrick smyrick added changes: minor Changes require a minor version module: generator Issue affects the schema generator and federation code labels Aug 4, 2021
Copy link
Collaborator

@dariuszkuc dariuszkuc left a comment

Choose a reason for hiding this comment

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

Can you update 4.x docs as well?

@dariuszkuc dariuszkuc merged commit 3497692 into ExpediaGroup:4.x.x Aug 12, 2021
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 module: generator Issue affects the schema generator and federation code
Development

Successfully merging this pull request may close these issues.

2 participants