Hello! Is there any way to add Kotlin extension fu...
# graphql-kotlin
d
Hello! Is there any way to add Kotlin extension functions to schema generation? I have read some issues related to my question - if I understand correctly, graphql kotlin does not provide special funcionality for generating extension functions. But is there any workaround for this?
Copy code
data class First(
      val id: Long,
      val name: String
) {
   fun second(env: DataFetchingEnvironment): Second {
      //query second class
   }
}

fun First.another(env: DataFetchingEnvironment): Another {
// I need this function to be seen in graphql schema and resolver
}
d
hello 👋 we currently don’t support processing extension functions out of the box
you should be able to add this functionality through schema hooks
a
@Dariusz Kuc can you give us an example how to add support for extension function to schema generation using schema hooks? In
generateObject
there is no hook called where you pass as parameters the
kClass
and the
GraphQLObjectType
or
GraphQLObjectType.Builder
. We need a hook with this parameters to enhance the generated
GraphQLObjectType
with additional field and not to have to rewrite all the logic to generate a
GraphQLObjectType
.
d