Skip to content

GreenDonut.DataLoaderBase#LoadAsync should have Task<TValue?> as return type instead of Task<TValue> #2911

Closed

Description

@simonwacker

Describe the bug
The method GreenDonut.DataLoaderBase#LoadAsync may return null although its return type suggests that it does not. Note that the method's non-generic variant has the correct Task<object?> as return type.

To Reproduce
Call the method for example on in instance of a batch data loader whose LoadBatchAsync method always returns an empty dictionary. The return value (after executing the task) is null.

Activity

  1. michaelstaib commented on Jan 21, 2021

    @michaelstaib
    Member

    It may return null depending on your implementation. Meaning, if you implement a DataLoader that does not return null then it won't. So, we leave the definition of TValue up to the implementor.

  2. self-assigned this
    on Jan 21, 2021
  3. added
    ❓ question
    on Jan 21, 2021
  4. simonwacker commented on Jan 21, 2021

    @simonwacker
    Author

    Then maybe it's an issue with the AttendeeByIdDataLoader from the GraphQL workshop? When you call LoadAsync on an instance of it as in AttendeeQueries#GetAttendeeByIdAsync with a valid but non-existent identifier, then null is being returned from LoadAsync and the query responds with an InternalServerError with the code EXEC_NON_NULL_VIOLATION, although all types check. Can't this issue be caught by the type system? Or is the real problem in the implementation of AttendeeByIdDataLoader#LoadBatchAsync which should have one value, either an Attendee instance or null, in the dictionary for each given identifier (which would force the type Attendee?)? Thanks for your great work!

  5. michaelstaib commented on Jan 21, 2021

    @michaelstaib
    Member

    Actually, this is then handled correctly by the execution engine. The execution engine is preventing an item to be null where the type system states that it is non nullable.

  6. ghost locked as resolved and limited conversation to collaborators on Jan 22, 2021
  7. removed
    ❓ question
    on Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions