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

[generator] support repeatable directives #590

Closed
dariuszkuc opened this issue Feb 1, 2020 · 6 comments · Fixed by #1360
Closed

[generator] support repeatable directives #590

dariuszkuc opened this issue Feb 1, 2020 · 6 comments · Fixed by #1360
Labels
module: generator Issue affects the schema generator and federation code status: blocked upstream We can not resolve until another outside issue is complete type: enhancement New feature or request

Comments

@dariuszkuc
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
GraphQL spec now supports repeated directives. graphql-kotlin-schema-generator should support it as well.

Describe the solution you'd like
graphql-kotlin-schema-generator should be able to generate a schema with fields that have repeated directives.

Describe alternatives you've considered
N/A

Additional context
GraphQL spec PR: graphql/graphql-spec#472

@dariuszkuc dariuszkuc added the type: enhancement New feature or request label Feb 1, 2020
@smyrick
Copy link
Contributor

smyrick commented Feb 22, 2020

We should wait until support is added in graphql-java before we support this in our library: graphql-java/graphql-java#1763

smyrick added a commit that referenced this issue Jun 30, 2020
The GraphQL spec does now support repeatable directives but we are tracking support here: #590
dariuszkuc pushed a commit that referenced this issue Jul 1, 2020
The GraphQL spec does now support repeatable directives but we are tracking support here: #590
@smyrick smyrick added the status: blocked upstream We can not resolve until another outside issue is complete label Aug 28, 2020
@smyrick smyrick added the module: generator Issue affects the schema generator and federation code label Nov 25, 2020
@elucidator
Copy link

Issue seems to be resolved in 16.0

Any progess on this planned?

@dariuszkuc dariuszkuc added status: blocked upstream We can not resolve until another outside issue is complete and removed status: blocked upstream We can not resolve until another outside issue is complete labels Jan 22, 2021
@dariuszkuc
Copy link
Collaborator Author

I just looked into this and while graphql-java does support repeatable directives, unfortunately Kotlin still does not support repeatable annotations with RUNTIME retention (see https://youtrack.jetbrains.com/issue/KT-12794). We need RUNTIME retention on the directive annotations so we can access them using reflections.

Suggested workaround of using some wrapper annotation won't work as annotations do not extend other annotations so we won't be able to pass instances of custom directives.

annotation class GraphQLRepeatableDirectives(
    val directives: Array<GraphQLDirective>
)

@GraphQLRepeatableDirectives(
  directives = [CustomDirective("foo")] // type mismatch 
)
class Foo(val bar: String)

Based on the above I am unsure whether we will be able to support repeatable directives until https://youtrack.jetbrains.com/issue/KT-12794 is resolved or we move away from annotations.

@elucidator
Copy link

elucidator commented Jan 23, 2021 via email

@mchandramouli
Copy link

Any update on this? @elucidator's suggestion to have an Array<FieldSet> will help. Are there any other workarounds?

@dariuszkuc
Copy link
Collaborator Author

According to Kotlin Roadmap they will be tackling KT-12794 in the next couple months.

Proposed solution of using Array<FieldSet> would require some custom processing logic just for this single directive. Guess we could potentially add another schema generator hook specifically for building out the directives.

dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this issue Feb 13, 2022
Kotlin 1.6 provides support for repeatable annotations with `RUNTIME` retention. This allows to finally support repeatable directives.

Related Issues:
* resolves ExpediaGroup#590
* depends on ExpediaGroup#1358
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this issue Feb 13, 2022
Kotlin 1.6 provides support for repeatable annotations with `RUNTIME` retention. This allows to finally support repeatable directives.

In order to make your directives repeatable, you need to annotate it with `kotlin.annotation.Repeatable` annotation.

```kotlin
@repeatable
@GraphQLDirective
annotation class MyRepeatableDirective(val value: String)
```

Generates the above directive as

```graphql
directive @myRepeatableDirective(value: String!) repeatable on OBJECT | INTERFACE
```

Related Issues:
* resolves ExpediaGroup#590
* depends on ExpediaGroup#1358
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this issue Feb 13, 2022
Kotlin 1.6 provides support for repeatable annotations with `RUNTIME` retention. This allows to finally support repeatable directives.

In order to make your directives repeatable, you need to annotate it with `kotlin.annotation.Repeatable` annotation.

```kotlin
@repeatable
@GraphQLDirective
annotation class MyRepeatableDirective(val value: String)
```

Generates the above directive as

```graphql
directive @myRepeatableDirective(value: String!) repeatable on OBJECT | INTERFACE
```

Related Issues:
* resolves ExpediaGroup#590
* depends on ExpediaGroup#1358
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this issue Feb 14, 2022
Kotlin 1.6 provides support for repeatable annotations with `RUNTIME` retention. This allows to finally support repeatable directives.

In order to make your directives repeatable, you need to annotate it with `kotlin.annotation.Repeatable` annotation.

```kotlin
@repeatable
@GraphQLDirective
annotation class MyRepeatableDirective(val value: String)
```

Generates the above directive as

```graphql
directive @myRepeatableDirective(value: String!) repeatable on OBJECT | INTERFACE
```

Related Issues:
* resolves ExpediaGroup#590
* depends on ExpediaGroup#1358
dariuszkuc pushed a commit that referenced this issue Feb 14, 2022
Kotlin 1.6 provides support for repeatable annotations with `RUNTIME` retention. This allows to finally support repeatable directives.

In order to make your directives repeatable, you need to annotate it with `kotlin.annotation.Repeatable` annotation.

```kotlin
@repeatable
@GraphQLDirective
annotation class MyRepeatableDirective(val value: String)
```

Generates the above directive as

```graphql
directive @myRepeatableDirective(value: String!) repeatable on OBJECT | INTERFACE
```

Related Issues:
* resolves #590
* depends on #1358
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this issue Aug 5, 2022
The GraphQL spec does now support repeatable directives but we are tracking support here: ExpediaGroup#590
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this issue Aug 5, 2022
Kotlin 1.6 provides support for repeatable annotations with `RUNTIME` retention. This allows to finally support repeatable directives.

In order to make your directives repeatable, you need to annotate it with `kotlin.annotation.Repeatable` annotation.

```kotlin
@repeatable
@GraphQLDirective
annotation class MyRepeatableDirective(val value: String)
```

Generates the above directive as

```graphql
directive @myRepeatableDirective(value: String!) repeatable on OBJECT | INTERFACE
```

Related Issues:
* resolves ExpediaGroup#590
* depends on ExpediaGroup#1358
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: generator Issue affects the schema generator and federation code status: blocked upstream We can not resolve until another outside issue is complete type: enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

4 participants