Hello, I am trying to use <gradle plugin to genera...
# graphql-kotlin
a
Hello, I am trying to use gradle plugin to generate GraphQL schema file(s) from types defined in kotlin code. I keep getting this error:
Copy code
Execution failed for task ':graphqlGenerateSDL'.
> There was a failure while executing work items
   > A failure occurred while executing com.expediagroup.graphql.plugin.gradle.actions.GenerateSDLAction
      > Cannot calculate JVM erasure for type: ...
Any suggestions on how to address this? The version is 4.1.1 for both
graphql-kotlin-spring-server
and
graphql-kotlin-gradle-plugin
d
erasure implies generics (and generics are not supported)?
a
The model per se does not have generics. Its curious that the server actually presents the full generated schema after startup, just that the gradle plugin fails with this error.
Here is the stack trace:
Copy code
com.doordash.consumer.bff.graphql.schema.model.consumer.Consumer
        at kotlin.reflect.jvm.KTypesJvm.getJvmErasure(KTypesJvm.kt:36)
        at com.expediagroup.graphql.generator.internal.extensions.KTypeExtensionsKt.getKClass(kTypeExtensions.kt:38)
        at com.expediagroup.graphql.generator.internal.extensions.KTypeExtensionsKt.isSubclassOf(kTypeExtensions.kt:42)
        at com.expediagroup.graphql.generator.internal.types.utils.FunctionReturnTypesKt.checkTypeForDataFetcherResult(functionReturnTypes.kt:62)
        at com.expediagroup.graphql.generator.internal.types.utils.FunctionReturnTypesKt.getWrappedReturnType(functionReturnTypes.kt:46)
        at com.expediagroup.graphql.generator.internal.types.GenerateFunctionKt.generateFunction(generateFunction.kt:53)
        at com.expediagroup.graphql.generator.internal.types.GenerateFunctionKt.generateFunction$default(generateFunction.kt:33)
        at com.expediagroup.graphql.generator.internal.types.GenerateQueryKt.generateQueries(generateQuery.kt:43)
        at com.expediagroup.graphql.generator.SchemaGenerator.generateSchema(SchemaGenerator.kt:80)
        at com.expediagroup.graphql.generator.SchemaGenerator.generateSchema$default(SchemaGenerator.kt:73)
        at com.expediagroup.graphql.generator.ToSchemaKt.toSchema(toSchema.kt:41)
        at com.expediagroup.graphql.plugin.schema.GenerateSDLKt.generateSDL(GenerateSDL.kt:94)
        at com.expediagroup.graphql.plugin.gradle.actions.GenerateSDLAction.execute(GenerateSDLAction.kt:39)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
        at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
        at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
        at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.lambda$execute$0(IsolatedClassloaderWorkerFactory.java:58)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
        at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.execute(IsolatedClassloaderWorkerFactory.java:50)
        at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:214)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
        ... 3 more
d
without seeing the code that reproduces this issue its hard to say since SDL generation relies on the same logic to generate the schema it might be some misconfiguration (e.g. not providing custom hooks to the plugin) or it might be an actual bug (latest version is
5.3.2
)
a
Ah, Let me dig in to custom hooks a bit more. I it still does not work will try to produce sample code to illustrate. Thanks!
a
I have upgraded to 5.3.2 and am using the Hooks-provider as suggested. I am running in to this issue:
Copy code
Execution failed for task ':graphqlGenerateSDL'.
> There was a failure while executing work items
   > A failure occurred while executing com.expediagroup.graphql.plugin.gradle.actions.GenerateSDLAction
      > The configured packages do not contain any valid classes:
Double checked the package name is correct. Also, since I am only using the schema generation in my. project, I have removed other tasks that were erroring out due to missing configuration, Do you think this could have a bad side effect?:
Copy code
project.gradle.startParameter.excludedTaskNames.add('graphqlGenerateClient')
project.gradle.startParameter.excludedTaskNames.add('graphqlGenerateTestClient')
d
👋 without a repository that reproduces the error it is hard to guess what is the issue
GenerateSDLAction
complains that there are no valid classes in the specified packages
a
Yes I can imagine 🙂. I am working on a repo to share.
Seems like this is working correctly and identifies the queries and mutations in the packages. However the subsequent call to ClassGraph from ClassScanner seems to be returning scanResult with empty package info.