Skip to content

Is the data loader's per-key context allowed to be null? #76

@skingsland

Description

@skingsland

Based on looking at the code and testing it, it appears that this data fetcher will pass through the key context to the data loader, even if it's null:

    TypeRuntimeWiring.newTypeWiring("Query")
        .dataFetcher(
            "myField",
            environment -> {
              String myId = environment.getArgument("myId");
              
              // it's OK if this is null, because the keyContext is allowed to be null?
              Integer myKeyContext = getNullableKeyContext(...);

              return environment.getDataLoader("myLoader").load(myId, myKeyContext);
            })
        .build();

Can you confirm, that though? Because nothing I found in the Javadocs or https://www.graphql-java.com/documentation/v16/batching#passing-context-to-your-data-loader says whether the per-key context is allowed to be null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions