Skip to content

Generated code has compilation errors #327

@adlaika

Description

@adlaika

Issue Description

Attempting to generate code based on minimal schema results in compilation error in generated code.

Steps to Reproduce

Minimal schema:

type Query {
    product(
        companyId: ID!
    ): Product!
}

interface Product {
    linkCode(
        pid: ID!
    ): LinkCode
}

type LinkCode {
    html: String
}

Actual Result

mvn clean compile results in:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/marnold/gits/product-search-api-java-client-graphql-java-codegen/target/generated-sources/graphql1/com/cj/product_api/graphql/model/ProductResponseProjection.java:[42,47] cannot find symbol
  symbol:   class ProductLinkCodeParametrizedInput
  location: class com.cj.product_api.graphql.model.ProductResponseProjection
[ERROR] /Users/marnold/gits/product-search-api-java-client-graphql-java-codegen/target/generated-sources/graphql1/com/cj/product_api/graphql/model/ProductResponseProjection.java:[46,61] cannot find symbol
  symbol:   class ProductLinkCodeParametrizedInput
  location: class com.cj.product_api.graphql.model.ProductResponseProjection

Your Environment and Setup

pom follows:

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>product-search-api-java-client-graphql-java-codegen</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <codegen.version>3.1.0</codegen.version>
    </properties>

    <build>
        <plugins>
            <!-- GraphQL Codegen Maven plugin -->
            <plugin>
                <groupId>io.github.kobylynskyi</groupId>
                <artifactId>graphql-codegen-maven-plugin</artifactId>
                <!-- use the latest available version:
                https://search.maven.org/artifact/io.github.kobylynskyi/graphql-codegen-maven-plugin -->
                <version>${codegen.version}</version>
                <executions>
                    <execution>
                        <id>graphqlCodegenService1</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <graphqlSchemaPaths>${project.basedir}/src/main/resources/schema1.graphqls</graphqlSchemaPaths>
                            <outputDir>${project.build.directory}/generated-sources/graphql1</outputDir>
                            <modelPackageName>com.cj.product_api.graphql.model</modelPackageName>
                            <customTypesMapping>
                                <DateTime>java.util.Date</DateTime>
                            </customTypesMapping>
                            <generateApis>false</generateApis>
                            <generateClient>true</generateClient>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- GraphQL Codegen Maven plugin -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.8</source>
                    <target>1.8</target>
                    <showDeprecation>true</showDeprecation>
                    <annotationProcessorPaths>
                        <annotationProcessorPath>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>1.18.12</version>
                        </annotationProcessorPath>
                        <annotationProcessorPath>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>1.3.1.Final</version>
                        </annotationProcessorPath>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>graphql-spring-boot-starter</artifactId>
            <version>7.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>graphiql-spring-boot-starter</artifactId>
            <version>7.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.graphql-java</groupId>
            <artifactId>graphql-java-extended-scalars</artifactId>
            <version>1.0.1</version>
        </dependency>

        <dependency>
            <groupId>io.github.kobylynskyi</groupId>
            <artifactId>graphql-java-codegen</artifactId>
            <!-- use the latest available version:
            https://search.maven.org/artifact/io.github.kobylynskyi/graphql-java-codegen -->
            <version>${codegen.version}</version>
        </dependency>
    </dependencies>


</project>

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions