Skip to content

DataFetchingEnvironment getDataLoader doesn't match DataLoader signature #4179

Description

@ctbarbour

Describe the bug

DataFetchingEnvironment.getDataLoader<K, V>() has type parameters that are implicitly non-null due to @NullMarked but DataLoader<K, V extends @Nullable Object> explicitly allows nullable V. This creates a type mismatch when calling from Kotlin. As of Kotlin 2.1.0, Kotlin compiler treats JSpecify types as null-safe types.

To Reproduce

From Kotlin, attempt to get a DataLoader with a nullable value type:

// Kotlin sees getDataLoader as requiring V : Any
val loader: DataLoader<String, Player?>? = env.getDataLoader("PlayerLoader")
// Error: Type argument is not within its bounds: must be subtype of 'Any'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    keep-openTells Stale Bot to keep PRs and issues open

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions