Skip to content

Commit 36ebb1c

Browse files
authored
Merge pull request #214 from brphelps/master
Fix stack overflow when using DateTimeOffset params
2 parents 285fc1b + f62be94 commit 36ebb1c

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Octokit.GraphQL.Core.UnitTests/Models/Repository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public Repository(Expression expression) : base(expression)
2020
public ID Id { get; }
2121
public string Name { get; }
2222
public Repository Parent => this.CreateProperty(x => x.Parent, Create);
23+
public Issue IssueByCreation(Arg<DateTimeOffset> createdSince = default) => this.CreateMethodCall(x => x.IssueByCreation(createdSince), Models.Issue.Create);
2324
public Issue Issue(Arg<int> number) => this.CreateMethodCall(x => x.Issue(number), Models.Issue.Create);
2425
public IssueOrPullRequest IssueOrPullRequest(Arg<int> number) => this.CreateMethodCall(x => x.IssueOrPullRequest(number), Models.IssueOrPullRequest.Create);
2526
public IssueConnection Issues(Arg<int>? first = null, Arg<string>? after = null, Arg<int>? last = null, Arg<string>? before = null, Arg<IEnumerable<string>>? labels = null) => this.CreateMethodCall(x => x.Issues(first, after, last, before, labels), IssueConnection.Create);

Octokit.GraphQL.Core.UnitTests/QueryBuilderTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,20 @@ public void IntValue_Variable()
469469
Assert.Equal(expected, query.ToString(0));
470470
}
471471

472+
[Fact]
473+
public void DateTimeOffsetValue_Variable()
474+
{
475+
var expected = "query{repository(owner:\"foo\",name:\"bar\"){issueByCreation(createdSince:\"2000-01-02T03:04:05+00:00\"){body}}}";
476+
var expression = new Query()
477+
.Repository("foo", "bar")
478+
.IssueByCreation(new DateTimeOffset(2000,1,2,3,4,5, default))
479+
.Select(x => x.Body);
480+
481+
var query = expression.Compile();
482+
483+
Assert.Equal(expected, query.ToString(0));
484+
}
485+
472486
[Fact]
473487
public void InputObject_Variable()
474488
{

Octokit.GraphQL.Core/Core/Serializers/QuerySerializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ private void SerializeValue(StringBuilder builder, object value)
200200
{
201201
builder.Append(JsonConvert.ToString(id.Value, '"'));
202202
}
203+
else if (value is DateTimeOffset dto)
204+
{
205+
builder.Append(JsonConvert.ToString(dto, DateFormatHandling.IsoDateFormat));
206+
}
203207
else if (value is IEnumerable)
204208
{
205209
builder.Append("[");

0 commit comments

Comments
 (0)