diff --git a/src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/packages.lock.json b/src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/packages.lock.json index 7ce0959f115..4c59178e94a 100644 --- a/src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/packages.lock.json +++ b/src/HotChocolate/AspNetCore/src/AspNetCore.Authorization.Opa/packages.lock.json @@ -1,382 +1,6 @@ { "version": 1, "dependencies": { - ".NETStandard,Version=v2.0": { - "Microsoft.Extensions.Configuration.Abstractions": { - "type": "Direct", - "requested": "[6.0.0, )", - "resolved": "6.0.0", - "contentHash": "qWzV9o+ZRWq+pGm+1dF+R7qTgTYoXvbyowRoBxQJGfqTpqDun2eteerjRQhq5PQ/14S+lqto3Ft4gYaRyl4rdQ==", - "dependencies": { - "Microsoft.Extensions.Primitives": "6.0.0" - } - }, - "Microsoft.Extensions.Http": { - "type": "Direct", - "requested": "[6.0.0, )", - "resolved": "6.0.0", - "contentHash": "15+pa2G0bAMHbHewaQIdr/y6ag2H3yh4rd9hTXavtWDzQBkvpe2RMqFg8BxDpcQWssmjmBApGPcw93QRz6YcMg==", - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0", - "Microsoft.Extensions.Logging": "6.0.0", - "Microsoft.Extensions.Logging.Abstractions": "6.0.0", - "Microsoft.Extensions.Options": "6.0.0" - } - }, - "Microsoft.SourceLink.GitHub": { - "type": "Direct", - "requested": "[1.1.1, )", - "resolved": "1.1.1", - "contentHash": "IaJGnOv/M7UQjRJks7B6p7pbPnOwisYGOIzqCz5ilGFTApZ3ktOR+6zJ12ZRPInulBmdAf1SrGdDG2MU8g6XTw==", - "dependencies": { - "Microsoft.Build.Tasks.Git": "1.1.1", - "Microsoft.SourceLink.Common": "1.1.1" - } - }, - "NETStandard.Library": { - "type": "Direct", - "requested": "[2.0.3, )", - "resolved": "2.0.3", - "contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", - "dependencies": { - "Microsoft.NETCore.Platforms": "1.1.0" - } - }, - "Microsoft.Bcl.AsyncInterfaces": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.Bcl.HashCode": { - "type": "Transitive", - "resolved": "1.1.1", - "contentHash": "MalY0Y/uM/LjXtHfX/26l2VtN4LDNZ2OE3aumNOHDLsT4fNYy2hiHXI4CXCqKpNUNm7iJ2brrc4J89UdaL56FA==" - }, - "Microsoft.Build.Tasks.Git": { - "type": "Transitive", - "resolved": "1.1.1", - "contentHash": "AT3HlgTjsqHnWpBHSNeR0KxbLZD7bztlZVj7I8vgeYG9SYqbeFGh0TM/KVtC6fg53nrWHl3VfZFvb5BiQFcY6Q==" - }, - "Microsoft.Extensions.DependencyInjection": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "k6PWQMuoBDGGHOQTtyois2u4AwyVcIwL2LaSLlTZQm2CYcJ1pxbt6jfAnpWmzENA/wfrYRI/X9DTLoUkE4AsLw==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0", - "System.Runtime.CompilerServices.Unsafe": "6.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.Extensions.DependencyInjection.Abstractions": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "xlzi2IYREJH3/m6+lUrQlujzX8wDitm4QGnUu6kUXTQAWPuZY8i+ticFJbzfqaetLA6KR/rO6Ew/HuYD+bxifg==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "Microsoft.Extensions.Logging": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "eIbyj40QDg1NDz0HBW0S5f3wrLVnKWnDJ/JtZ+yJDFnDj90VoPuoPmFkeaXrtu+0cKm5GRAwoDf+dBWXK0TUdg==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "Microsoft.Extensions.DependencyInjection": "6.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0", - "Microsoft.Extensions.Logging.Abstractions": "6.0.0", - "Microsoft.Extensions.Options": "6.0.0", - "System.Diagnostics.DiagnosticSource": "6.0.0" - } - }, - "Microsoft.Extensions.Logging.Abstractions": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/HggWBbTwy8TgebGSX5DBZ24ndhzi93sHUBDvP1IxbZD7FDokYzdAr6+vbWGjw2XAfR2EJ1sfKUotpjHnFWPxA==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4" - } - }, - "Microsoft.Extensions.ObjectPool": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "7hR9FU0JJHOCLmn/Ary31pLLAhlzoMptBKs5CJmNUzD87dXjl+/NqVkyCTl6cT2JAfTK0G39HpvCOv1fhsX3BQ==" - }, - "Microsoft.Extensions.Options": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "dzXN0+V1AyjOe2xcJ86Qbo233KHuLEY0njf/P2Kw8SfJU+d45HNS2ctJdnEnrWbM9Ye2eFgaC5Mj9otRMU6IsQ==", - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0", - "Microsoft.Extensions.Primitives": "6.0.0", - "System.ComponentModel.Annotations": "5.0.0" - } - }, - "Microsoft.Extensions.Primitives": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "9+PnzmQFfEFNR9J2aDTfJGGupShHjOuGw4VUv+JB044biSHrnmCIMD+mJHmb2H7YryrfBEXDurxQ47gJZdCKNQ==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "Microsoft.NETCore.Platforms": { - "type": "Transitive", - "resolved": "1.1.0", - "contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==" - }, - "Microsoft.SourceLink.Common": { - "type": "Transitive", - "resolved": "1.1.1", - "contentHash": "WMcGpWKrmJmzrNeuaEb23bEMnbtR/vLmvZtkAP5qWu7vQsY59GqfRJd65sFpBszbd2k/bQ8cs8eWawQKAabkVg==" - }, - "System.Buffers": { - "type": "Transitive", - "resolved": "4.5.1", - "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" - }, - "System.Collections.Immutable": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "l4zZJ1WU2hqpQQHXz1rvC3etVZN+2DLmQMO79FhOTZHMn8tDRr+WU287sbomD0BETlmKDn0ygUgVy9k5xkkJdA==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.ComponentModel.Annotations": { - "type": "Transitive", - "resolved": "5.0.0", - "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==" - }, - "System.Diagnostics.DiagnosticSource": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "frQDfv0rl209cKm1lnwTgFPzNigy2EKk1BS3uAvHvlBVKe5cymGyHO+Sj+NLv5VF/AhHsqPIUUwya5oV4CHMUw==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.5", - "contentHash": "XIWiDvKPXaTveaB7HVganDlOCRoj03l+jrwNvcge/t8vhGYKvqV+dMv6G4SAX2NoNmN0wZfVPTAlFwZcZvVOUw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Numerics.Vectors": "4.4.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.Numerics.Vectors": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" - }, - "System.Text.Encodings.Web": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "Vg8eB5Tawm1IFqj4TVK1czJX89rhFxJo9ELqc/Eiq0eXy13RK00eubyU6TJE6y+GQXjyV5gSfiewDUZjQgSE0w==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - }, - "System.Text.Json": { - "type": "Transitive", - "resolved": "6.0.7", - "contentHash": "/Tf/9XjprpHolbcDOrxsKVYy/mUG/FS7aGd9YUgBVEiHeQH4kAE0T1sMbde7q6B5xcrNUsJ5iW7D1RvHudQNqA==", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "6.0.0", - "System.Buffers": "4.5.1", - "System.Memory": "4.5.4", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "6.0.0", - "System.Text.Encodings.Web": "6.0.0", - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "System.Threading.Channels": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "TY8/9+tI0mNaUMgntOxxaq2ndTkdXqLSxvPmas7XEqOlv9lQtB7wLjYGd756lOaO7Dvb5r/WXhluM+0Xe87v5Q==", - "dependencies": { - "System.Threading.Tasks.Extensions": "4.5.4" - } - }, - "System.Threading.Tasks.Extensions": { - "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg==", - "dependencies": { - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "greendonut": { - "type": "Project", - "dependencies": { - "Microsoft.Extensions.ObjectPool": "[6.0.0, )", - "System.Diagnostics.DiagnosticSource": "[6.0.0, )", - "System.Threading.Tasks.Extensions": "[4.5.0, )" - } - }, - "HotChocolate": { - "type": "Project", - "dependencies": { - "HotChocolate.Authorization": "[0.0.0, )", - "HotChocolate.Execution": "[0.0.0, )", - "HotChocolate.Fetching": "[0.0.0, )", - "HotChocolate.Types": "[0.0.0, )", - "HotChocolate.Types.CursorPagination": "[0.0.0, )", - "HotChocolate.Types.Mutations": "[0.0.0, )", - "HotChocolate.Types.OffsetPagination": "[0.0.0, )", - "HotChocolate.Validation": "[0.0.0, )" - } - }, - "hotchocolate.abstractions": { - "type": "Project", - "dependencies": { - "HotChocolate.Language": "[0.0.0, )", - "Microsoft.Bcl.AsyncInterfaces": "[6.0.0, )", - "System.Collections.Immutable": "[6.0.0, )" - } - }, - "hotchocolate.authorization": { - "type": "Project", - "dependencies": { - "HotChocolate.Execution": "[0.0.0, )" - } - }, - "hotchocolate.execution": { - "type": "Project", - "dependencies": { - "HotChocolate.Abstractions": "[0.0.0, )", - "HotChocolate.Execution.Abstractions": "[0.0.0, )", - "HotChocolate.Fetching": "[0.0.0, )", - "HotChocolate.Types": "[0.0.0, )", - "HotChocolate.Validation": "[0.0.0, )", - "Microsoft.Extensions.DependencyInjection": "[6.0.0, )", - "System.Threading.Channels": "[6.0.0, )" - } - }, - "hotchocolate.execution.abstractions": { - "type": "Project", - "dependencies": { - "HotChocolate.Abstractions": "[0.0.0, )", - "Microsoft.Extensions.DependencyInjection.Abstractions": "[6.0.0, )" - } - }, - "hotchocolate.fetching": { - "type": "Project", - "dependencies": { - "GreenDonut": "[0.0.0, )", - "HotChocolate.Types": "[0.0.0, )" - } - }, - "hotchocolate.language": { - "type": "Project", - "dependencies": { - "HotChocolate.Language.SyntaxTree": "[0.0.0, )", - "HotChocolate.Language.Utf8": "[0.0.0, )", - "HotChocolate.Language.Visitors": "[0.0.0, )", - "HotChocolate.Language.Web": "[0.0.0, )" - } - }, - "hotchocolate.language.syntaxtree": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.HashCode": "[1.1.1, )", - "Microsoft.Extensions.ObjectPool": "[6.0.0, )", - "System.Memory": "[4.5.5, )", - "System.Threading.Tasks.Extensions": "[4.5.4, )" - } - }, - "hotchocolate.language.utf8": { - "type": "Project", - "dependencies": { - "HotChocolate.Language.SyntaxTree": "[0.0.0, )" - } - }, - "hotchocolate.language.visitors": { - "type": "Project", - "dependencies": { - "HotChocolate.Language.SyntaxTree": "[0.0.0, )" - } - }, - "hotchocolate.language.web": { - "type": "Project", - "dependencies": { - "HotChocolate.Language.Utf8": "[0.0.0, )" - } - }, - "hotchocolate.types": { - "type": "Project", - "dependencies": { - "HotChocolate.Abstractions": "[0.0.0, )", - "HotChocolate.Types.Shared": "[0.0.0, )", - "HotChocolate.Utilities": "[0.0.0, )", - "Microsoft.Extensions.DependencyInjection.Abstractions": "[6.0.0, )", - "Microsoft.Extensions.ObjectPool": "[6.0.0, )", - "System.ComponentModel.Annotations": "[5.0.0, )", - "System.Text.Json": "[6.0.7, )" - } - }, - "hotchocolate.types.cursorpagination": { - "type": "Project", - "dependencies": { - "HotChocolate.Execution": "[0.0.0, )", - "HotChocolate.Types": "[0.0.0, )" - } - }, - "hotchocolate.types.mutations": { - "type": "Project", - "dependencies": { - "HotChocolate.Execution": "[0.0.0, )", - "HotChocolate.Types": "[0.0.0, )" - } - }, - "hotchocolate.types.offsetpagination": { - "type": "Project", - "dependencies": { - "HotChocolate.Execution": "[0.0.0, )", - "HotChocolate.Types": "[0.0.0, )" - } - }, - "hotchocolate.types.shared": { - "type": "Project", - "dependencies": { - "HotChocolate.Language.SyntaxTree": "[0.0.0, )" - } - }, - "hotchocolate.utilities": { - "type": "Project", - "dependencies": { - "Microsoft.Bcl.AsyncInterfaces": "[6.0.0, )", - "System.Memory": "[4.5.5, )", - "System.Threading.Tasks.Extensions": "[4.5.4, )" - } - }, - "hotchocolate.validation": { - "type": "Project", - "dependencies": { - "HotChocolate.Types": "[0.0.0, )", - "Microsoft.Extensions.DependencyInjection.Abstractions": "[6.0.0, )", - "Microsoft.Extensions.Options": "[6.0.0, )" - } - } - }, "net6.0": { "Microsoft.Extensions.Configuration.Abstractions": { "type": "Direct", diff --git a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs index 03d93e568b9..bd2ea4a9449 100644 --- a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs +++ b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatter.cs @@ -189,6 +189,11 @@ public void Format(IQueryResult result, IBufferWriter writer) throw new ArgumentNullException(nameof(writer)); } + FormatInternal(result, writer); + } + + private void FormatInternal(IQueryResult result, IBufferWriter writer) + { using var jsonWriter = new Utf8JsonWriter(writer, _options); WriteResult(jsonWriter, result); jsonWriter.Flush(); @@ -218,11 +223,20 @@ private async ValueTask FormatInternalAsync( Stream outputStream, CancellationToken cancellationToken = default) { - await using var writer = new Utf8JsonWriter(outputStream, _options); - - WriteResult(writer, result); + using var buffer = new ArrayWriter(); + FormatInternal(result, buffer); + +#if NETSTANDARD2_0 + await outputStream + .WriteAsync(buffer.GetInternalBuffer(), 0, buffer.Length, cancellationToken) + .ConfigureAwait(false); +#else + await outputStream + .WriteAsync(buffer.GetWrittenMemory(), cancellationToken) + .ConfigureAwait(false); +#endif - await writer.FlushAsync(cancellationToken).ConfigureAwait(false); + await outputStream.FlushAsync(cancellationToken).ConfigureAwait(false); } private void WriteResult(Utf8JsonWriter writer, IQueryResult result) diff --git a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatterOptions.cs b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatterOptions.cs index f2b70d3abd1..718654fd16b 100644 --- a/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatterOptions.cs +++ b/src/HotChocolate/Core/src/Execution/Serialization/JsonResultFormatterOptions.cs @@ -31,13 +31,17 @@ public struct JsonResultFormatterOptions public JavaScriptEncoder? Encoder { get; set; } internal JsonWriterOptions CreateWriterOptions() - => new() { Indented = Indented, Encoder = Encoder }; + => new() + { + Indented = Indented, + Encoder = Encoder ?? JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; internal JsonSerializerOptions CreateSerializerOptions() => new(Web) { WriteIndented = Indented, - Encoder = Encoder, + Encoder = Encoder ?? JavaScriptEncoder.UnsafeRelaxedJsonEscaping, DefaultIgnoreCondition = NullIgnoreCondition is Fields or All ? WhenWritingNull