@GraphQLID support for List<ID>
See original GitHub issueI might be missing something—is it possible to use the @GraphQLID
annotation on a List<String>
?
class Query {
fun thingsByID(@GraphQLID ids: List<String>): List<Thing> = ...
When version 2.1.1, I get:
com.expediagroup.graphql.exceptions.InvalidIdTypeException: List is not a valid ID type, only Strings are accepted
I have a workaround, but I wanted to check to see if I was just doing something wrong:
typealias ID = String
class Query {
fun thingsByID(ids: List<ID>): List<Thing> = ...
}
class CustomSchemaGeneratorHooks(
federatedTypeRegistry: FederatedTypeRegistry
) : FederatedSchemaGeneratorHooks(federatedTypeRegistry) {
override fun willGenerateGraphQLType(type: KType): GraphQLType? = when (type.classifier as? KClass<*>) {
ID::class -> Scalars.GraphQLID
else -> super.willGenerateGraphQLType(type)
}
}
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Global Object Identification - GraphQL
A GraphQL server compatible with this spec must reserve certain types and type names to support the consistent object identification model.
Read more >GraphQL API Resources - GitLab Docs
This documentation is self-generated based on GitLab current GraphQL schema. The API can be explored interactively using the GraphiQL IDE.
Read more >.Net 5 API with GraphQL - Step by Step - DEV Community
GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and ......
Read more >Wishlist - GraphQL | Verbb
Wishlist supports accessing Item and List objects via GraphQL. Be sure to read about Craft's GraphQL support (opens new window). .
Read more >Exploring the security implications of GraphQL - Fastly
It might be tempting to use introspection to help users learn how to query the API, but separate documentation (such as readthedocs) is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
wow, fantastic guys, thanks a ton for making this happen so quickly, I’ve just hit this issue with the previous version and I’m now happily back to my work using the 3.0 RC 😃
Awesome! Not expecting a blazing fast response!
I’m all for a wrapper type if that’s the direction you decide to go. I had a few moments to try to support the annotation and I think I have it working: https://github.com/ExpediaGroup/graphql-kotlin/compare/master...lennyburdette:lenny/support-lists-of-ids?expand=1
But I agree that passing the
annotatedAsId
around everywhere isn’t fun.