-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked the invalid GraphQL name error message. (#7939)
- Loading branch information
1 parent
a329840
commit 4eb11c3
Showing
8 changed files
with
92 additions
and
22 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
...snapshots__/SortConventionTests.SortConvention_Should_Fail_When_OperationsIsNotNamed.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
For more details look at the `Errors` property. | ||
|
||
1. The specified name is not a valid GraphQL name. (Parameter 'definition.Name') (HotChocolate.Data.Sorting.SortConventionTests.FooSortType) | ||
1. `` is not a valid GraphQL name. | ||
https://spec.graphql.org/October2021/#sec-Names | ||
(Parameter 'definition.Name') (HotChocolate.Data.Sorting.SortConventionTests.FooSortType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 21 additions & 15 deletions
36
src/HotChocolate/Primitives/src/Primitives/Properties/PrimitivesResources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/HotChocolate/Primitives/test/Primitives.Tests/HotChocolate.Primitives.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current"> | ||
|
||
<PropertyGroup> | ||
<AssemblyName>HotChocolate.Primitives.Tests</AssemblyName> | ||
<RootNamespace>HotChocolate.Primitives</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Primitives\HotChocolate.Primitives.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
36 changes: 36 additions & 0 deletions
36
src/HotChocolate/Primitives/test/Primitives.Tests/NameUtilsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using HotChocolate.Utilities; | ||
|
||
namespace HotChocolate.Primitives; | ||
|
||
public class NameUtilsTests | ||
{ | ||
[Theory] | ||
[InlineData("1Bar")] | ||
[InlineData("$Bar")] | ||
[InlineData("1_Bar")] | ||
[InlineData("B/ar")] | ||
[InlineData("B+ar")] | ||
public void InvalidName(string name) | ||
{ | ||
var message = Assert.Throws<ArgumentException>(() => name.EnsureGraphQLName()).Message; | ||
Assert.Equal( | ||
$"`{name}` is not a valid GraphQL name.{Environment.NewLine}" | ||
+ $"https://spec.graphql.org/October2021/#sec-Names{Environment.NewLine}" | ||
+ $" (Parameter 'name')", | ||
message); | ||
} | ||
|
||
[Theory] | ||
[InlineData("_1Bar")] | ||
[InlineData("Bar")] | ||
[InlineData("_Bar")] | ||
[InlineData("Bar123")] | ||
[InlineData("Bar_123")] | ||
[InlineData("ABCDEFGHIJKLMNOPQRSTUVWXYZ")] | ||
[InlineData("abcdefghijklmnopqrstuvwxyz")] | ||
[InlineData("_1234567890")] | ||
public void ValidName(string name) | ||
{ | ||
name.EnsureGraphQLName(); | ||
} | ||
} |