Skip to content

Commit f47e557

Browse files
authored
Fix issue with Date as variable (graphql-dotnet#745)
fixes graphql-dotnet#744
1 parent 4e74411 commit f47e557

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/GraphQL.StarWars/GraphQL.StarWars.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
<PropertyGroup>
44
<Version>1.0.0</Version>
5-
<TargetFrameworks>netstandard1.3;net45</TargetFrameworks>
6-
<PackageTargetFallback>dnxcore50</PackageTargetFallback>
5+
<TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>
76
<AssemblyName>GraphQL.StarWars</AssemblyName>
87
<PackageId>GraphQL.StarWars</PackageId>
98
<PackageProjectUrl>https://github.com/graphql-dotnet/graphql-dotnet</PackageProjectUrl>

src/GraphQL.Tests/Types/DateGraphTypeTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ public class DateGraphTypeTests
1010
{
1111
private readonly DateGraphType _type = new DateGraphType();
1212

13+
[Fact]
14+
public void serialize_string_to_date()
15+
{
16+
CultureTestHelper.UseCultures(() =>
17+
{
18+
var actual = _type.Serialize("2018-07-24");
19+
actual.ShouldBe("2018-07-24");
20+
});
21+
}
22+
1323
[Fact]
1424
public void serialize_local_date_returns_date_only()
1525
{

src/GraphQL/Types/DateGraphType.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ public DateGraphType()
1414

1515
public override object Serialize(object value)
1616
{
17-
if (value is DateTime dateTime)
17+
var date = ParseValue(value);
18+
19+
if (date is DateTime dateTime)
1820
{
1921
return dateTime.ToString("yyyy-MM-dd");
2022
}

0 commit comments

Comments
 (0)