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
32 changes: 24 additions & 8 deletions src/GraphQLParser.Tests/ParserTests.Throw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,36 @@ public void Should_Throw_If_Descriptions_Not_Allowed(string query)
[Fact]
public void Should_Throw_On_Unknown_Cases_From_ExpectOneOf()
{
var context = new ParserContext("abc", default);
Should.Throw<NotSupportedException>(() => context.ParseNamedDefinition(new[] { "abc" }))
Should.Throw<NotSupportedException>(
() =>
{
var context = new ParserContext("abc", default);
context.ParseNamedDefinition(new[] { "abc" });
})
.Message.ShouldBe("Unexpected keyword 'abc' in ParseNamedDefinition.");

context = new ParserContext("abc", default);
Should.Throw<NotSupportedException>(() => context.ParseOperationType(new[] { "abc" }))
Should.Throw<NotSupportedException>(
() =>
{
var context = new ParserContext("abc", default);
context.ParseOperationType(new[] { "abc" });
})
.Message.ShouldBe("Unexpected keyword 'abc' in ParseOperationType.");

context = new ParserContext("abc", default);
Should.Throw<NotSupportedException>(() => context.ParseDirectiveLocation(new[] { "abc" }))
Should.Throw<NotSupportedException>(
() =>
{
var context = new ParserContext("abc", default);
context.ParseDirectiveLocation(new[] { "abc" });
})
.Message.ShouldBe("Unexpected keyword 'abc' in ParseDirectiveLocation.");

context = new ParserContext("extend abc", default);
Should.Throw<NotSupportedException>(() => context.ParseTypeExtension(new[] { "abc" }))
Should.Throw<NotSupportedException>(
() =>
{
var context = new ParserContext("extend abc", default);
context.ParseTypeExtension(new[] { "abc" });
})
.Message.ShouldBe("Unexpected keyword 'abc' in ParseTypeExtension.");
}
}
4 changes: 2 additions & 2 deletions src/GraphQLParser/ParserContext.Parse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace GraphQLParser;

// WARNING: mutable struct, pass it by reference to those methods that will change it
internal partial struct ParserContext
// WARNING: mutable ref struct, pass it by reference to those methods that will change it
internal ref partial struct ParserContext
{
// http://spec.graphql.org/October2021/#Document
public GraphQLDocument ParseDocument()
Expand Down
5 changes: 3 additions & 2 deletions src/GraphQLParser/ParserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

namespace GraphQLParser;

// WARNING: mutable struct, pass it by reference to those methods that will change it
internal partial struct ParserContext
// WARNING: mutable ref struct, pass it by reference to those methods that will change it

internal ref partial struct ParserContext
{
private static string[] TopLevelKeywordOneOf { get; set; } = new[]
{
Expand Down