is there a way to split up a schema into multiple ...
# kgraphql
m
is there a way to split up a schema into multiple files to keep it more readable?
1
j
Yes, I personally like the pattern that you would usually use with ktor routes. You can just create a function anywhere you want like this
Copy code
fun SchemaBuilder.user() {
  query("users") {
    ...
  }
}
And then you can call this function within your main schema
m
awesome
is there a spot for this in the DOcs? I cant seem to find it?
j
No, currently there is not. I'm noting it down, I will add some examples to the docs some time soon. But you can see a simple example of this within our example project here: https://github.com/aPureBase/KGraphQL/blob/master/kgraphql-example/src/main/kotlin/com/apurebase/kgraphql/Application.kt#L38 Where the
ufoSchema
function is defined here: https://github.com/aPureBase/KGraphQL/blob/master/kgraphql-example/src/main/kotlin/com/apurebase/kgraphql/GraphQLSchema.kt
Currently in that example there is only one, but you can of course grow this list with multiple files and just make sure to call that function somewhere within the
SchemaBuilder
context