Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private ArgumentValue CreateArgumentValue(
_inputValueParser.ParseLiteral(value, argument),
value);
}
catch (LeafCoercionException ex)
catch (GraphQLException ex)
{
return new ArgumentValue(argument, ex.Errors[0]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using HotChocolate.Execution;
using Microsoft.Extensions.DependencyInjection;

namespace HotChocolate.Types.Relay;

public class Issue7346Tests
{
[Fact]
public async Task Invalid_Id_Does_Not_Erase_Sibling_Data()
{
var result =
await new ServiceCollection()
.AddGraphQLServer()
.AddQueryType<ProbeQuery>()
.AddGlobalObjectIdentification(false)
.ExecuteRequestAsync(
"""
{
byId(id: "invalid")
unrelated
}
""");

result.ToJson().MatchInlineSnapshot(
"""
{
"errors": [
{
"message": "The node ID string has an invalid format.",
"path": [
"byId"
],
"extensions": {
"originalValue": "invalid"
}
}
],
"data": {
"byId": null,
"unrelated": "value"
}
}
""");
}

[Fact]
public async Task Invalid_Id_On_Skipped_Field_Does_Not_Error()
{
var result =
await new ServiceCollection()
.AddGraphQLServer()
.AddQueryType<ProbeQuery>()
.AddGlobalObjectIdentification(false)
.ExecuteRequestAsync(
"""
{
byId(id: "invalid") @skip(if: true)
unrelated
}
""");

result.ToJson().MatchInlineSnapshot(
"""
{
"data": {
"unrelated": "value"
}
}
""");
}

public class ProbeQuery
{
public int? GetById([ID] int id) => id;

public string GetUnrelated() => "value";
}
}
Loading