Skip to content

Conversation

@matnun-br
Copy link
Contributor

No description provided.

This comment was marked as outdated.

@matnun-br matnun-br requested a review from Copilot June 19, 2025 05:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a NonNull attribute to explicitly mark GraphQL fields that cannot be null when queried, improving schema expressiveness. Key changes include:

  • Appending the [NonNull] attribute during type generation if the field type is NON_NULL.
  • Adding a NonNullAttribute implementation in the Abstractions layer.
  • Updating various GraphQL API model classes (including tests) to annotate appropriate properties with [NonNull].

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
GraphQLSharp/TypeGenerator/GraphQLTypeGenerator.cs Appends the [NonNull] attribute for NON_NULL fields during generation
GraphQLSharp/Abstractions/NonNullAttribute.cs Defines the NonNull attribute
GraphQLSharp.Tests/square.cs Updates GraphQL model classes to include the [NonNull] attribute
Comments suppressed due to low confidence (2)

GraphQLSharp/TypeGenerator/GraphQLTypeGenerator.cs:301

  • Consider adding a clarifying comment here that explains the purpose of appending the [NonNull] attribute, and how this annotation aligns with the C# nullable reference types for future maintainability.
        if (f.type.kind == GraphQLTypeKind.NON_NULL)

GraphQLSharp.Tests/square.cs:43

  • When marking a property as NonNull, consider using a non-nullable reference type (i.e. removing the '?' from the type) if the field truly can never be null, to better reflect the intended contract in C#.
        [NonNull]

@clement911 clement911 merged commit 4aac4c1 into main Jun 19, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants