Skip to content

Commit 62d14d2

Browse files
committed
Fixed result formatting when non-null root field becomes null. (#6844)
1 parent f3623c9 commit 62d14d2

File tree

111 files changed

+912
-720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+912
-720
lines changed

src/CookieCrumble/src/CookieCrumble/Snapshot.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace CookieCrumble;
1616

17-
public sealed class Snapshot
17+
public class Snapshot
1818
{
1919
private static readonly object _sync = new();
2020
private static readonly UTF8Encoding _encoding = new();
@@ -49,6 +49,9 @@ public Snapshot(string? postFix = null, string? extension = null)
4949

5050
public static Snapshot Create(string? postFix = null, string? extension = null)
5151
=> new(postFix, extension);
52+
53+
public static DisposableSnapshot Start(string? postFix = null, string? extension = null)
54+
=> new(postFix, extension);
5255

5356
public static void Match(
5457
object? value,
@@ -474,3 +477,10 @@ public SnapshotSegment(string? name, object? value, ISnapshotValueFormatter form
474477
public ISnapshotValueFormatter Formatter { get; }
475478
}
476479
}
480+
481+
public sealed class DisposableSnapshot(string? postFix = null, string? extension = null)
482+
: Snapshot(postFix, extension)
483+
, IDisposable
484+
{
485+
public void Dispose() => Match();
486+
}

src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/__snapshots__/AuthorizationHandlerTests.Authorize_NoDefaultPolicy.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"code": "AUTH_NO_DEFAULT_POLICY"
1616
}
1717
}
18-
]
18+
],
19+
"data": null
1920
}

src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/__snapshots__/AuthorizationHandlerTests.Authorize_NotAllowed.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"code": "AUTH_NOT_AUTHORIZED"
1616
}
1717
}
18-
]
18+
],
19+
"data": null
1920
}

src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/__snapshots__/AuthorizationHandlerTests.Authorize_NotAuthenticated.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"code": "AUTH_NOT_AUTHENTICATED"
1616
}
1717
}
18-
]
18+
],
19+
"data": null
1920
}

src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/__snapshots__/AuthorizationHandlerTests.Authorize_PolicyNotFound.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"code": "AUTH_POLICY_NOT_FOUND"
1616
}
1717
}
18-
]
18+
],
19+
"data": null
1920
}

src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/__snapshots__/AuthorizeSchemaTests.AuthorizeOnExtension.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"code": "AUTH_NOT_AUTHORIZED"
1616
}
1717
}
18-
]
18+
],
19+
"data": null
1920
}

src/HotChocolate/Caching/test/Caching.Tests/__snapshots__/HttpCachingTests.MaxAgeAndScope_Should_Cache.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
]
1616
}
1717
],
18-
"Body": "{\"data\":{\"field\":\"\"}}"
18+
"Body": "{}"
1919
}

src/HotChocolate/Caching/test/Caching.Tests/__snapshots__/HttpCachingTests.MaxAge_NonZero_Should_Cache.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
]
1616
}
1717
],
18-
"Body": "{\"data\":{\"field\":\"\"}}"
18+
"Body": "{}"
1919
}

src/HotChocolate/Caching/test/Caching.Tests/__snapshots__/HttpCachingTests.MaxAge_Zero_Should_Cache.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
]
1616
}
1717
],
18-
"Body": "{\"data\":{\"field\":\"\"}}"
18+
"Body": "{}"
1919
}

src/HotChocolate/Core/src/Abstractions/Execution/IQueryResult.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public interface IQueryResult : IExecutionResult
6262
/// </summary>
6363
/// <value></value>
6464
bool? HasNext { get; }
65+
66+
/// <summary>
67+
/// Specifies if data was explicitly set.
68+
/// If <c>false</c> the data was not set (including null).
69+
/// </summary>
70+
bool IsDataSet { get; }
6571

6672
/// <summary>
6773
/// Serializes this GraphQL result into a dictionary.

0 commit comments

Comments
 (0)