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

[feature] support @oneOf directive #1891

Open
fediazgon opened this issue Nov 22, 2023 · 3 comments
Open

[feature] support @oneOf directive #1891

fediazgon opened this issue Nov 22, 2023 · 3 comments
Labels
type: enhancement New feature or request

Comments

@fediazgon
Copy link

graphql-java added support for the @oneOf directive in the 21.2 release. I understand that graphql-kotlin is still using the 21.1 release, but I was wondering if I will be able to use this directive out-of-the-box.

In the docs I can see that other directives like @skip are supported:

However, how do I annotate my schema and use graphql-kotlin-schema-generator to generate this annotations for me? What I want is to write Kotlin code like this:

@GraphqlOneOf
data class Some(
 val a: String?
 val b: Int?
)

and graphql-kotlin-schema-generator will generate code like:

type Some @oneOf { ... }

Do I have to use custom directives for this?

@dariuszkuc dariuszkuc changed the title How to annotate schema to use directives supported by graphql-java? [feature] support @oneOf directive Nov 23, 2023
@dariuszkuc
Copy link
Collaborator

Hello 👋
Currently there is no built-in mechanism to support it as @oneOf is still not part of the GraphQL spec. While some implementations already added the support, RFC is still open (but it is getting close to be finalized). Once RFC is merged to the spec we'll work on adding the support.

Haven't tried it but 'm guessing you might be able to support it by writing some custom hooks + data fetcher that could handle some sort of wrapper.

Thanks,
Derek

@dariuszkuc dariuszkuc added the type: enhancement New feature or request label Nov 23, 2023
@fediazgon
Copy link
Author

fediazgon commented Nov 23, 2023

Thanks for the prompt response.

My second part of the question was: it seems there are multiple directives that are supported according to the docs (e.g., @skip, @include). However these do not have their corresponding annotation in com.expediagroup.graphql.generator.annotations as, for example, @deprecated has @GraphQLDeprecated. How do I annotate my Kotlin schema to make use of these annotations?

@dariuszkuc
Copy link
Collaborator

@skip/@include are executable directives so they are not part of your schema but instead are provided by clients writing their queries. Since there is nothing to represent in the schema, we don't provide annotations for them.

@specifiedBy directive is a schema directive that is applicable on custom scalars so technically we could provide corresponding annotation... but since you still need to provide manual configuration for your custom scalars (e.g. coercing logic) it's seemed like that would be the right place to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Development

No branches or pull requests

2 participants