https://kotlinlang.org logo
#apollo-kotlin
Title
# apollo-kotlin
r

rocketraman

01/19/2023, 7:51 PM
My GraphQL server has a scalar type which converts to a list (ugh!). If I try to create a custom type mapping to
"kotlin.List<kotlin.String>"
I get an invalid character on
<
. Is there a way to have my custom type mapping be a list? If not, I'll create a wrapper type.
m

mbonnin

01/19/2023, 7:53 PM
Apollo Kotlin doesn't support generic types for custom scalars but you can use a wrapper type
I'm hoping to revamp the custom scalar mapping with 4.0
r

rocketraman

01/19/2023, 7:54 PM
Amazing, thanks
m

mbonnin

01/19/2023, 7:55 PM
Sure thing!
It's still a very rough idea but I'd love to have something like this:
Copy code
@GraphQLAdapter(for = "Long")
class LongAdapter: Adapter<Long> {
  override fun fromJson(...): Long {
    //..
  }

  override fun toJson(...) {
    // ...
  }
}
This way all the custom scalar would be known at compile time
64 Views