Skip to content

Maven GraphQL Schema Location

dermakov edited this page Dec 30, 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 the plugin execution configuration.

Explicitly specification of schema files location

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

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <build>
        <plugins>
            <plugin>
                <groupId>io.github.ermadmi78</groupId>
                <artifactId>kobby-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-kotlin</goal>
                        </goals>
                        <configuration>
                            <schema>
                                <files>
                                    <file>src/main/resources/my/package/name/query.graphqls</file>
                                    <file>src/main/resources/my/package/name/mutation.graphqls</file>
                                    <file>src/main/resources/my/package/name/subscription.graphqls</file>
                                </files>
                            </schema>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Schema files search configuration

If the files section 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:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <build>
        <plugins>
            <plugin>
                <groupId>io.github.ermadmi78</groupId>
                <artifactId>kobby-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-kotlin</goal>
                        </goals>
                        <configuration>
                            <schema>
                                <scan>
                                    <!-- Root directory to scan schema files -->
                                    <dir>src/main/resources</dir>

                                    <!-- List of ANT style include patterns to scan schema files -->
                                    <includes>
                                        <include>**/*.graphqls</include>
                                    </includes>

                                    <!-- List of ANT style exclude patterns to scan schema files -->
                                    <excludes>
                                    </excludes>
                                </scan>
                            </schema>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
  • 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 **/*.graphqls.
  • excludes is the list of ANT style patterns to exclude matching files. By default, is empty.