Skip to content

How to map Set -> List #1110

Answered by dariuszkuc
dave-at-season asked this question in Q&A
Apr 2, 2021 · 2 comments · 20 replies
Discussion options

You must be logged in to vote

Hello 👋
I think the "simplest" way would be to follow the suggestion from #584 with small update -> with latest code you can just pass the additional types to the generator directly.

  1. Create custom SchemaGeneratorHooks
override fun willGenerateGraphQLType(type: KType): GraphQLType? = when (type.classifier) {
  Set::class -> GraphQLList.list(GraphQLTypeReference.typeRef(type.getTypeOfFirstArgument().getSimpleName()))
  else -> super.willGenerateGraphQLType(type)
}

override fun isValidSuperclass(kClass: KClass<*>): Boolean {
  return if(kClass == Set::class) false else  super.isValidSuperclass(kClass)
}
  1. Generate schema by explicitly passing additional Set types to ensure they get generated

Replies: 2 comments 20 replies

Comment options

You must be logged in to vote
10 replies
@dariuszkuc
Comment options

@dave-at-season
Comment options

@dave-at-season
Comment options

@smyrick
Comment options

@dave-at-season
Comment options

Answer selected by smyrick
Comment options

You must be logged in to vote
10 replies
@tyrantkhan
Comment options

@coolbharat78
Comment options

@smyrick
Comment options

@coolbharat78
Comment options

@smyrick
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #1109 on April 02, 2021 20:48.