Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQLIgnore annotation not respected when running GraalVM native image #1896

Open
simboel opened this issue Dec 3, 2023 · 0 comments
Open
Labels
type: bug Something isn't working

Comments

@simboel
Copy link
Contributor

simboel commented Dec 3, 2023

Library Version

Name Version
kotlin 1.9.21
graphql-kotlin 7.0.2
ktor + CIO 2.3.6
GraalVM (Community Edition) 21 (21.0.1+12-jvmci-23.1-b19)
Gradle 8.4

Describe the bug

It seems like @GraphQLIgnore is not respected by the schema generator when running as GraalVM native image.

Note: This problem is only true for @GraphQLIgnore on function level.

  • When using @GraphQLIgnore on a function parameter, it works as expected and without problems (ie. fun onlySecondParameterShouldNotBePartOfSchema(first: Int, @GraphQLIgnore second: Int) : Int = first + second).
  • When using @GraphQLIgnore on attributes (var/val) it works as expected, too.

To Reproduce

GraphQLIgnore no respected in general

class MyQuery : Query {
    fun shouldBePartOfSchema(): Boolean = true

    @GraphQLIgnore
    fun shouldNotBePartOfSchema(): Int = 2
}

When this is executed with a JRE the following schema is generated:

type Query {
  shouldBePartOfSchema: Boolean!
}

When executed as GraalVM native image (ie. ./gradlew nativeRun), the following incorrect schema is generated:

type Query {
  shouldBePartOfSchema: Boolean!
  shouldNotBePartOfSchema: Int!
}

By the way:
If the function with @GraphQLIgnore annoation contains unsupported GraphQL types, the application will not even start as the schema generator will throw InvalidInputFieldTypeException or TypeNotSupportedException depending on whether it was an input parameter or return type.

Expected behavior

I would expect the schema to be identical - no matter which runtime (JRE or native image) is being used.
shouldNotBePartOfSchema shall not be part of the schema as it is annotated with @GraphQLIgnore.

It seems like GraalVM native image is using a different kind of schema generation method or at least comes with some limitations. It will not respect the @GraphQLIgnore annotations.

Please either fix the schema generation for GraalVM native image based executables or describe the limitations (ie. @GraphQLIgnore is not working with GraalVM native image).

Example Project

The following project contains an example for this bug.

native-graphqlignore-bug.zip

  • Execute ./gradlew nativeRun for the problem
  • Execute ./gradlew runFatJar for the validation with the JVM
@simboel simboel added the type: bug Something isn't working label Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Development

No branches or pull requests

1 participant