Skip to content

Nullability Updates (v2.0) #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 81 commits into from
Nov 26, 2023

Conversation

kevin-carroll
Copy link
Member

Updates

  • Made all intermediate graph types (created when using pathed templates on controller actions) non-nullable by default in the schema. This should greatly reduce the noise generated by client code generators.
    • this can be turned off using the new format strategy object
  • Added the ability to programmatically manipulate some aspects of schema items as they are being generated. This will be expanded on in future releases.
    • Added a GraphSchemaFormatStrategyBuilder object to quickly build a custom format strategy.
    • GraphNameFormatStrategy was merged into the new GraphSchemaFormatStrategy object
    • A custom format strategy can be set at startup via options.DeclarationOptions.SchemaFormatStrategy
    • Added support to declare reference types, strings and lists as being "non-nullable" out of the box without having to declare a custom type expression on each field or argument.
    • Users can inherit from GraphSchemaFormatStrategy and build fully custom setups
// Program.cs

// Example format strategy creation that will treat all strings and lists as being "not nullable".
var schemaFormatStrategy = GraphSchemaFormatStrategyBuilder.Create()
    .WithRequiredStrings()
    .WithRequiredLists()
    .Build();

builder.Services..AddGraphQL(o =>
{
    o.DeclarationOptions.SchemaFormatStrategy = schemaFormatStrategy;
})

Minor Breaking Changes

  • Removed GraphNameFormatter and merged its functionality into the new GraphSchemaFormatStrategy object.

Detailed ChangeLog

  • Removed GraphNameFormatStrategy and replaced it with GraphSchemaFormatStrategy, expanding its capabilities
  • Renamed SchemaItemPath to just ItemPath to better clarify its intent
  • Renamed GraphSchemaCollections to ItemPathRoots
    • Merged ItemPathRoots.Enums and ItemPathRoots.Scalars into ItemPathRoots.Types
    • Removed ItemPathRoots.Documents it is no longer necessary
  • Renamed GraphArgumentModifiers to ParameterModifiers to better clarify its intent, as it no longer plays a direct role in a graph schema.

Also:
* decoupled directive resolver methods from templates
* removed non-schema arguments from the schema data (only exists in resovler meta data)
@graphql-aspnet-owner graphql-aspnet-owner marked this pull request as draft November 26, 2023 20:18
@kevin-carroll kevin-carroll marked this pull request as ready for review November 26, 2023 20:25
@kevin-carroll kevin-carroll merged commit 16aac72 into release/2.0 Nov 26, 2023
@kevin-carroll kevin-carroll deleted the feature/55-minimalApi-nullability-strategy branch November 26, 2023 21:06
@kevin-carroll kevin-carroll added the v2.0 To be completed for the v2.0 release label Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.0 To be completed for the v2.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants