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.

@GraphQLID support for List<ID>

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
christianrybecommented, May 14, 2020

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 😃

0reactions
lennyburdettecommented, May 8, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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