Skip to content

Nullability of reference type dictionary values is not correctly translated to schema #5470

@thekatze

Description

@thekatze

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In a Project with nullable reference types enabled and a GraphQL mutation endpoint like this:

public class Mutation {
    public record WorkItem(string Id, string? Description);
    public Task<Dictionary<string, WorkItem?>> DoWork(Dictionary<string, WorkItem?> workItems)
    {
        // Do Work ...
        return Task.FromResult(workItems);
    }
}

The generated GraphQL Schema looks like this:

type Mutation {
  doWork(input: DoWorkInput!): DoWorkPayload!
}

input DoWorkInput {
  workItems: [KeyValuePairOfStringAndWorkItemInput!]!
}

input KeyValuePairOfStringAndWorkItemInput {
  key: String!
  value: WorkItemInput!
}

input WorkItemInput {
  id: String!
  description: String
}

The value: WorkItemInput! in KeyValuePairOfStringAndWorkItemInput should be nullable as is defined in Dictionary<string, WorkItem?>, but it is non-nullable.

Steps to reproduce

Full Reproduction in Repository: https://github.com/TheKatze/HotChocolateNullableRepro

Product

Hot Chocolate

Version

12.14.0, 13.0.0-preview.66

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions