forked from ChilliCream/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refined support for records. (ChilliCream#2331)
- Loading branch information
1 parent
b6d7dd9
commit 40d9772
Showing
7 changed files
with
276 additions
and
9 deletions.
There are no files selected for viewing
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
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
33 changes: 33 additions & 0 deletions
33
src/HotChocolate/Core/test/Types.Records.Tests/HotChocolate.Types.Records.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,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net5.0</TargetFrameworks> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<AssemblyName>HotChocolate.Types.Tests</AssemblyName> | ||
<RootNamespace>HotChocolate</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Core\HotChocolate.Core.csproj" /> | ||
<ProjectReference Include="..\Utilities\HotChocolate.Tests.Utilities.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="$(MSBuildProjectDirectory)\__resources__\*.*"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="$(MSBuildProjectDirectory)\xunit.runner.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<!--For Visual Studio for Mac Test Explorer we need this reference here--> | ||
<ItemGroup> | ||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
49 changes: 49 additions & 0 deletions
49
src/HotChocolate/Core/test/Types.Records.Tests/RecordsTests.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,49 @@ | ||
using System; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using HotChocolate.Types.Relay; | ||
using static HotChocolate.Tests.TestHelper; | ||
using System.Threading.Tasks; | ||
using HotChocolate.Tests; | ||
using Snapshooter.Xunit; | ||
using Xunit; | ||
using HotChocolate.Execution; | ||
|
||
namespace HotChocolate.Types | ||
{ | ||
public class RecordsTests | ||
{ | ||
[Fact] | ||
public async Task Records_Clone_Member_Is_Removed() | ||
{ | ||
Snapshot.FullName(); | ||
|
||
await new ServiceCollection() | ||
.AddGraphQL() | ||
.AddQueryType<Query>() | ||
.Services | ||
.BuildServiceProvider() | ||
.GetSchemaAsync() | ||
.MatchSnapshotAsync(); | ||
} | ||
|
||
[Fact] | ||
public async Task Relay_Id_Middleware_Is_Correctly_Applied() | ||
{ | ||
Snapshot.FullName(); | ||
|
||
await ExpectValid | ||
( | ||
@"{ person { id name } }", | ||
b => b.AddQueryType<Query>() | ||
) | ||
.MatchSnapshotAsync(); ; | ||
} | ||
|
||
public class Query | ||
{ | ||
public Person GetPerson() => new Person(1, "Michael"); | ||
} | ||
|
||
public record Person([ID] int Id, string Name); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../test/Types.Records.Tests/__snapshots__/RecordsTests.Records_Clone_Member_Is_Removed.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
schema { | ||
query: Query | ||
} | ||
|
||
type Person { | ||
id: ID! | ||
name: String! | ||
} | ||
|
||
type Query { | ||
person: Person! | ||
} | ||
|
||
"The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID." | ||
scalar ID | ||
|
||
"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text." | ||
scalar String |
8 changes: 8 additions & 0 deletions
8
...es.Records.Tests/__snapshots__/RecordsTests.Relay_Id_Middleware_Is_Correctly_Applied.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"data": { | ||
"person": { | ||
"id": "UGVyc29uCmkx", | ||
"name": "Michael" | ||
} | ||
} | ||
} |