Netflix / dgs-framework

GraphQL for Java with Spring Boot made easy.
https://netflix.github.io/dgs
Apache License 2.0
3.08k stars 296 forks source link

bug: Unable to resolve codegen and client classes #1329

Closed onomesotu closed 1 year ago

onomesotu commented 1 year ago

Please read our contributor guide before creating an issue.

Expected behavior

 // GraphQL DGS dependencies
    def dgsVersion = '5.0.5'
    implementation(platform("com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:$dgsVersion"))
    implementation 'com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter'
    implementation 'com.netflix.graphql.dgs:graphql-dgs-extended-scalars'

Using DGS 5.0.5 as shown above and codegen plugin 5.1.17, I am able to use the following classes in tests:

import com.netflix.graphql.dgs.client.GraphQLClient;
import com.netflix.graphql.dgs.client.GraphQLResponse;
import com.netflix.graphql.dgs.client.codegen.EntitiesGraphQLQuery;
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;

Actual behavior

After updating DGS to 5.4.0, I am unable to reference the classes above with compilation errors. As they cannot be resolved.

Moving DGS to 5.3.0 fixes

import com.netflix.graphql.dgs.client.GraphQLClient;
import com.netflix.graphql.dgs.client.GraphQLResponse;

And I need to revert the plugin down to 5.1.17 to fix

import com.netflix.graphql.dgs.client.codegen.EntitiesGraphQLQuery;
import com.netflix.graphql.dgs.client.codegen.GraphQLQueryRequest;

I have read the release docs and can't find anything, in particular, that's causing this issue.

Steps to reproduce

Note: A test case would be highly appreciated, but we understand that's not always possible

benco03 commented 1 year ago

This can also be seen using the federation-example project. https://github.com/Netflix/dgs-federation-example/tree/master/reviews-dgs

The EntitiesGraphQLQuery class is not resolvable according to IntelliJ, despite the test being runnable and passing.

Dropping the codegen plugin to 5.1.0 allows IntelliJ to be able to resolve the classes.

image

benco03 commented 1 year ago

Turns out this is an issue with IntelliJ's version of Kotlin.

When viewing the sources, IntelliJ could not decompile because the version of Kotlin used was 1.7, whereas I was on an older version of Kotlin. The code used in DGS 5.1.0 must have been using older versions of Kotlin.

Ensure that you have the latest version of Kotlin by going Preferences -> Languages & Frameworks -> Kotlin and updating to the latest version.

image

onomesotu commented 1 year ago

Closing as it was an issue with the Intellij Kotlin plugin.