question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Directive arguments support @GraphQLIgnore

See original GitHub issue

Creating a new directive with an ignored field will prevent the schema from being generated when the ignored field type is not in the supported packages. Is there a way to prevent this behavior? It seems like a type that is only referred to in an ignored field should not break schema generation even if it is not in the supported packages.

Example in a directive:

@GraphQLDirective()
annotation class TestDirective(
        val value: String,
        @GraphQLIgnore
        val ignore: Array<KClass<*>> = [] 
)

Results in Caused by: com.expediagroup.graphql.exceptions.TypeNotSupportedException: Cannot convert kotlin.reflect.KClass<*> since it is not a valid GraphQL type or outside the supported packages [...]

Obviously something like kotlin.reflect should not be added to the supported packages and nothing representing KClass should be in the schema.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
smyrickcommented, Jun 11, 2020

@oatmeal-raisin From what I can tell there is no way to get the argument annotation information from a directive during schema generation unless you know the specific class type. So the best way to solve this is just with the hooks.

See the PR for more details https://github.com/ExpediaGroup/graphql-kotlin/pull/763

0reactions
oatmeal-raisincommented, Jun 11, 2020

Thanks @smyrick and @dariuszkuc. I really appreciate how responsive your team is and I am looking forward to the enhancement. Are there any hooks I can take a look at that do something similar? I will need to both exclude the field and to prevent the type on that ignored field from causing an exception because it is not in the configured packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Directives - Apollo GraphQL Docs
Directives · Configure GraphQL types, fields, and arguments · Valid locations · Default directives · Custom directives · Directives · Community · Company...
Read more >
Directives | GraphQL Kotlin
GraphQL directives can be used to transform the schema types, fields and arguments as well as modify the runtime.
Read more >
Field arguments vs. directives in GraphQL - LogRocket Blog
In conclusion, only field arguments can help retrieve the data that resolves the field. Applying functionality via field arguments or directives.
Read more >
Schema Directives – GraphQL Tools
Using and implementing custom directives to transform schema types, fields, and arguments.
Read more >
leangen/graphql-spqr - Gitter
I've got minor issue and i believe you can help me. ... to manipulate the schema elements that SPQR produces internally (fields, arguments...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found