Skip to content

DataFetchingEnvironment getDataLoader doesn't match DataLoader signature #4179

@ctbarbour

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions