Skip to content

Gradle GraphQL Schema Location

dermakov edited this page Jul 31, 2021 · 2 revisions

Kobby uses GraphQL schema to generate Kotlin DSL client. By default, Kobby looks for all files with extension graphqls in src/main/resources directory and all its subdirectories. You can change this behaviour by means of schema section in kobby plugin extension.

Explicitly specification of schema files location

You can specify schema files location explicitly by means of files property:

kobby {
    schema {
        files = files(
            "src/main/resources/my/package/name/query.graphqls",
            "src/main/resources/my/package/name/mutation.graphqls",
            "src/main/resources/my/package/name/subscription.graphqls"
        )
    }
}

The files property is of type FileCollection, so you can use the rich Gradle File API to configure it.

Schema files search configuration

If the files property is not explicitly specified, Kobby will look for schema files in the project files. You can use the scan section to customize your search parameters:

kobby {
    schema {
        scan {
            // Root directory to scan schema files
            dir = "src/main/resources" // String

            // ANT style include patterns to scan schema files
            includes = listOf("**/*.graphqls") // Iterable<String>

            // ANT style exclude patterns to scan schema files
            excludes = null // Iterable<String>
        }
    }
}
  • dir is the root directory to scan. By default, is src/main/resources.
  • includes is the list of ANT style patterns for including matching files. By default, is listOf("**/*.graphqls").
  • excludes is the list of ANT style patterns to exclude matching files. By default, is empty.