Skip to content

Commit

Permalink
Remove TrueNullability prototype (#7675)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-tengler authored Nov 4, 2024
1 parent ad8fdf0 commit cd808c6
Show file tree
Hide file tree
Showing 36 changed files with 171 additions and 625 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ public static class WellKnownContextData
/// </summary>
public const string AllowAnonymous = "HotChocolate.Authorization.AllowAnonymous";

/// <summary>
/// The key to access the true nullability flag on the execution context.
/// </summary>
public const string EnableTrueNullability = "HotChocolate.Types.EnableTrueNullability";

/// <summary>
/// The key to access the tag options object.
/// </summary>
Expand Down
10 changes: 0 additions & 10 deletions src/HotChocolate/Core/src/Execution/ErrorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,4 @@ public static IError ReadPersistedOperationMiddleware_PersistedOperationNotFound
.SetMessage("PersistedQueryNotFound")
.SetCode(ErrorCodes.Execution.PersistedOperationNotFound)
.Build();

public static IError NoNullBubbling_ArgumentValue_NotAllowed(
ArgumentNode argument)
{
var errorBuilder = ErrorBuilder.New();
errorBuilder.SetLocations([argument.Value]);
errorBuilder.SetMessage(ErrorHelper_NoNullBubbling_ArgumentValue_NotAllowed);

return errorBuilder.Build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ private IOperation CompileOperation(
operationType,
context.Schema,
_operationCompilerOptimizers.OperationOptimizers,
_operationCompilerOptimizers.SelectionSetOptimizers,
context.IsNullBubblingEnabled());
_operationCompilerOptimizers.SelectionSetOptimizers);

var compiler = _operationCompilerPool.Get();
var operation = compiler.Compile(request);
Expand Down
20 changes: 1 addition & 19 deletions src/HotChocolate/Core/src/Execution/Pipeline/PipelineTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,9 @@ public static string CreateCacheId(this IRequestContext context)

var operationId = CreateOperationId(documentId, operationName);

var flags = OperationFlags.Nothing;

if (!context.IsNullBubblingEnabled())
{
flags |= OperationFlags.DisableNullBubbling;
}

return $"{context.Schema.Name}-{context.ExecutorVersion}-{(int)flags}-{operationId}";
return $"{context.Schema.Name}-{context.ExecutorVersion}-{operationId}";
}

public static bool IsNullBubblingEnabled(this IRequestContext context)
=> !context.Schema.ContextData.ContainsKey(WellKnownContextData.EnableTrueNullability)
|| !context.ContextData.ContainsKey(WellKnownContextData.EnableTrueNullability);

public static IReadOnlyList<IVariableValueCollection> CoerceVariables(
IRequestContext context,
VariableCoercionHelper coercionHelper,
Expand Down Expand Up @@ -104,11 +93,4 @@ public static IReadOnlyList<IVariableValueCollection> CoerceVariables(

throw new NotSupportedException("Request type not supported.");
}

[Flags]
private enum OperationFlags
{
Nothing = 0,
DisableNullBubbling
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace HotChocolate.Execution.Processing;

public sealed partial class OperationCompiler
{
internal sealed class CompilerContext(ISchema schema, DocumentNode document, bool enableNullBubbling)
internal sealed class CompilerContext(ISchema schema, DocumentNode document)
{
public ISchema Schema { get; } = schema;

Expand All @@ -27,8 +27,6 @@ internal sealed class CompilerContext(ISchema schema, DocumentNode document, boo

public ImmutableArray<ISelectionSetOptimizer> Optimizers { get; private set; }

public bool EnableNullBubbling { get; } = enableNullBubbling;

public void Initialize(
ObjectType type,
SelectionVariants selectionVariants,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public IOperation Compile(OperationCompilerRequest request)
var variants = GetOrCreateSelectionVariants(id);
SelectionSetInfo[] infos = [new(request.Definition.SelectionSet, 0)];

var context = new CompilerContext(request.Schema, request.Document, request.EnableNullBubbling);
var context = new CompilerContext(request.Schema, request.Document);
context.Initialize(request.RootType, variants, infos, rootPath, selectionSetOptimizers);
CompileSelectionSet(context);

Expand Down Expand Up @@ -419,9 +419,7 @@ private void ResolveField(

if (context.Type.Fields.TryGetField(fieldName, out var field))
{
var fieldType = context.EnableNullBubbling
? field.Type
: field.Type.RewriteToNullableType();
var fieldType = field.Type;

if (context.Fields.TryGetValue(responseName, out var preparedSelection))
{
Expand Down Expand Up @@ -739,7 +737,7 @@ private CompilerContext RentContext(CompilerContext context)
{
if (_deferContext is null)
{
return new CompilerContext(context.Schema, context.Document, context.EnableNullBubbling);
return new CompilerContext(context.Schema, context.Document);
}

var temp = _deferContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public OperationCompilerRequest(
ObjectType rootType,
ISchema schema,
ImmutableArray<IOperationOptimizer>? operationOptimizers = null,
ImmutableArray<ISelectionSetOptimizer>? selectionSetOptimizers = null,
bool enableNullBubbling = true)
ImmutableArray<ISelectionSetOptimizer>? selectionSetOptimizers = null)
{
if (string.IsNullOrEmpty(id))
{
Expand All @@ -77,7 +76,6 @@ public OperationCompilerRequest(
Schema = schema ?? throw new ArgumentNullException(nameof(schema));
OperationOptimizers = operationOptimizers ?? ImmutableArray<IOperationOptimizer>.Empty;
SelectionSetOptimizers = selectionSetOptimizers ?? ImmutableArray<ISelectionSetOptimizer>.Empty;
EnableNullBubbling = enableNullBubbling;
}

/// <summary>
Expand Down Expand Up @@ -109,6 +107,4 @@ public OperationCompilerRequest(
public ImmutableArray<IOperationOptimizer> OperationOptimizers { get; }

public ImmutableArray<ISelectionSetOptimizer> SelectionSetOptimizers { get; }

public bool EnableNullBubbling { get; }
}
Loading

0 comments on commit cd808c6

Please sign in to comment.