Skip to content

Commit a4a26e3

Browse files
authored
Merge branch 'master' into fixes/227-inner-paging
2 parents 9675f5a + 795c18c commit a4a26e3

File tree

500 files changed

+17718
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

500 files changed

+17718
-341
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "master" ]
20+
schedule:
21+
- cron: '21 12 * * 1'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'csharp' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v3
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
52+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53+
# queries: security-extended,security-and-quality
54+
55+
56+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57+
# If this step fails, then you should remove it and run the build manually (see below)
58+
- name: Autobuild
59+
uses: github/codeql-action/autobuild@v2
60+
61+
# ℹ️ Command-line programs to run using the OS shell.
62+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63+
64+
# If the Autobuild fails above, remove it and uncomment the following three lines.
65+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66+
67+
# - run: |
68+
# echo "Run, Build Application using script"
69+
# ./location_of_script_within_repo/buildscript.sh
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v2
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard1.1</TargetFramework>
3+
<TargetFramework>netstandard2.0</TargetFramework>
44
<LangVersion>7.2</LangVersion>
55
</PropertyGroup>
66
<ItemGroup>
@@ -9,4 +9,4 @@
99
<ItemGroup>
1010
<Folder Include="Properties\" />
1111
</ItemGroup>
12-
</Project>
12+
</Project>

Octokit.GraphQL.Core/Core/Syntax/VariableDefinition.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public static string ToTypeName(Type type, bool isNullable)
3131
{
3232
name = "Boolean";
3333
}
34+
else if (type == typeof(DateTimeOffset))
35+
{
36+
name = "DateTime";
37+
}
3438
else if (type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
3539
{
3640
var inner = ToTypeName(type.GenericTypeArguments[0], false);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard1.1</TargetFramework>
3+
<TargetFramework>netstandard2.0</TargetFramework>
44
<RootNamespace>Octokit.GraphQL</RootNamespace>
55
<SignAssembly>true</SignAssembly>
66
<AssemblyOriginatorKeyFile>..\key.snk</AssemblyOriginatorKeyFile>
@@ -9,10 +9,10 @@
99
<LangVersion>7.2</LangVersion>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
12+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1313
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
1414
</ItemGroup>
1515
<ItemGroup>
1616
<Folder Include="Properties\" />
1717
</ItemGroup>
18-
</Project>
18+
</Project>

Octokit.GraphQL.IntegrationTests/Queries/IssueTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public async Task Can_Manually_Page_Issue_Comments_By_Node_Id()
122122
.Select(issue => new
123123
{
124124
issue.Id,
125-
Comments = issue.Comments(100, null, null, null).Select(page => new
125+
Comments = issue.Comments(100, null, null, null, null).Select(page => new
126126
{
127127
page.PageInfo.HasNextPage,
128128
page.PageInfo.EndCursor,
@@ -171,7 +171,7 @@ public async Task Can_AutoPage_Issue_Comments()
171171
.Select(issue => new
172172
{
173173
issue.Id,
174-
Comments = issue.Comments(null, null, null, null).AllPages().Select(comment => comment.Body).ToList(),
174+
Comments = issue.Comments(null, null, null, null, null).AllPages().Select(comment => comment.Body).ToList(),
175175
});
176176

177177
var result = await Connection.Run(query);
@@ -226,7 +226,7 @@ public async Task Can_AutoPage_Issues_With_Subquery()
226226
.Select(issue => new
227227
{
228228
issue.Id,
229-
Comments = issue.Comments(null, null, null, null).AllPages().Select(comment => comment.Body).ToList(),
229+
Comments = issue.Comments(null, null, null, null, null).AllPages().Select(comment => comment.Body).ToList(),
230230
});
231231

232232
var result = (await Connection.Run(query)).ToList();

Octokit.GraphQL.IntegrationTests/Queries/RepositoryTests.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public async Task Should_Run_Readme_Query()
5151
};
5252

5353
var result = await Connection.Run(query, vars);
54-
Assert.Equal(result.Login, "octokit");
55-
Assert.Equal(result.Name, "octokit.graphql.net");
54+
Assert.Equal("octokit", result.Login);
55+
Assert.Equal("octokit.graphql.net", result.Name);
5656
}
5757

5858
[IntegrationTest]
@@ -69,8 +69,8 @@ public async Task Should_Query_Repository_ByName()
6969
var repository = await Connection.Run(query);
7070

7171
Assert.NotNull(repository);
72-
Assert.Equal(repository.Name, "octokit.net");
73-
Assert.Equal(repository.DatabaseId, 7528679);
72+
Assert.Equal("octokit.net", repository.Name);
73+
Assert.Equal(7528679, repository.DatabaseId);
7474
}
7575

7676
[IntegrationTest]
@@ -86,11 +86,11 @@ public async Task Should_QueryRepositoryOwner_Repositories_OrderBy_Name_Ascendin
8686

8787
var repositoryNames = (await Connection.Run(query)).ToArray();
8888

89-
Assert.Contains("discussions", repositoryNames);
90-
Assert.Contains("go-octokit", repositoryNames);
91-
Assert.Contains("octokit.net", repositoryNames);
92-
Assert.Contains("octokit.objc", repositoryNames);
93-
Assert.Contains("octokit.rb", repositoryNames);
89+
Assert.Contains(".github", repositoryNames);
90+
Assert.Contains("action.js", repositoryNames);
91+
Assert.Contains("app-permissions", repositoryNames);
92+
Assert.Contains("app.js", repositoryNames);
93+
Assert.Contains("auth-action.js", repositoryNames);
9494
}
9595

9696
[IntegrationTest]
@@ -153,7 +153,7 @@ public async Task Query_Repository_Select_Inner_Simple_Fragment()
153153
var query = new Query()
154154
.Select(q => new
155155
{
156-
Name = q.Repository("octokit.net", "octokit").Select(fragment).SingleOrDefault()
156+
Name = q.Repository("octokit.net", "octokit", null).Select(fragment).SingleOrDefault()
157157
});
158158

159159

@@ -175,7 +175,7 @@ public async Task Query_Organization_Repositories_Select_Simple_Fragment()
175175

176176
var repositoryName = (await Connection.Run(query)).OrderByDescending(s => s).First();
177177

178-
Assert.Equal("webhooks.js", repositoryName);
178+
Assert.Equal("webhooks-methods.js", repositoryName);
179179
}
180180

181181
[IntegrationTest]
@@ -210,8 +210,8 @@ public async Task Query_Repository_Select_Object_Fragment_Twice()
210210
var query = new Query()
211211
.Select(q => new
212212
{
213-
repo1 = q.Repository("octokit.net", "octokit").Select(fragment).Single(),
214-
repo2 = q.Repository("octokit.graphql.net", "octokit").Select(fragment).Single(),
213+
repo1 = q.Repository("octokit.net", "octokit", null).Select(fragment).Single(),
214+
repo2 = q.Repository("octokit.graphql.net", "octokit", null).Select(fragment).Single(),
215215
});
216216

217217
var result = await Connection.Run(query);
@@ -233,7 +233,7 @@ public async Task Query_Repository_Select_Inner_Object_Fragment()
233233
var query = new Query()
234234
.Select(q => new
235235
{
236-
TestModel = q.Repository("octokit.net", "octokit").Select(fragment).SingleOrDefault()
236+
TestModel = q.Repository("octokit.net", "octokit", null).Select(fragment).SingleOrDefault()
237237
});
238238

239239

@@ -260,7 +260,7 @@ public async Task Query_Organization_Repositories_Select_Object_Fragment()
260260

261261
var testModelObject = (await Connection.Run(query)).OrderByDescending(s => s.StringField1).First();
262262

263-
Assert.Equal("webhooks.js", testModelObject.StringField1);
263+
Assert.Equal("webhooks-methods.js", testModelObject.StringField1);
264264
}
265265

266266
[IntegrationTest]
@@ -279,7 +279,7 @@ public async Task Query_Organization_Repositories_Select_Multiple_Object_Fragmen
279279
Member = organization.MembersWithRole(10, null, null, null).Nodes
280280
.Select(fragment).ToList().OrderBy(o => o.StringField1).First(),
281281

282-
MentionableUser = organization.Repository("octokit.net")
282+
MentionableUser = organization.Repository("octokit.net", null)
283283
.MentionableUsers(10, null, null, null, null).Nodes
284284
.Select(fragment).ToList().OrderBy(o => o.StringField1).First()
285285
});
@@ -370,7 +370,7 @@ public async Task Should_Query_RepositoryOwner_Repository_With_Fragment()
370370
var query = new Query().Select(q => new
371371
{
372372
repoOwner = q
373-
.Repository("octokit.net", "octokit")
373+
.Repository("octokit.net", "octokit", null)
374374
.Owner
375375
.Select(fragment)
376376
.SingleOrDefault()

Octokit.GraphQL.IntegrationTests/Queries/ViewerTests.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Linq;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
24
using System.Threading.Tasks;
35
using Octokit.GraphQL.Core;
46
using Octokit.GraphQL.IntegrationTests.Utilities;
@@ -52,7 +54,7 @@ public async Task Viewer_By_GraphyQL_Matches_Api()
5254

5355
Assert.NotNull(graphqlUser);
5456

55-
Assert.Equal(apiUser.AvatarUrl, graphqlUser.AvatarUrl);
57+
Assert.Equal(apiUser.AvatarUrl.Split("?").First(), graphqlUser.AvatarUrl.Split("?").First());
5658
Assert.Equal(apiUser.Bio, graphqlUser.Bio);
5759
Assert.Equal(apiUser.Company, graphqlUser.Company);
5860

@@ -88,5 +90,23 @@ public async Task Viewer_Has_No_OrganizationVerifiedDomainEmails_For_Octokit()
8890

8991
Assert.Empty(emails);
9092
}
93+
94+
[IntegrationTest]
95+
public async Task DateTime_Filter_Works()
96+
{
97+
var query = new GraphQL.Query()
98+
.Viewer.ContributionsCollection(from: Variable.Var("start"))
99+
.Select(c => c.User.Name);
100+
101+
var vars = new Dictionary<string, object>
102+
{
103+
{ "start", new DateTimeOffset(2000, 1, 2, 3, 4, 5, default) }
104+
};
105+
106+
var response = await Connection.Run(query.Compile(), vars);
107+
108+
// no server error
109+
Assert.NotNull(response);
110+
}
91111
}
92112
}

Octokit.GraphQL.Pack/Octokit.GraphQL.Pack.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard1.1</TargetFramework>
3+
<TargetFramework>netstandard2.0</TargetFramework>
44
<NoBuild>true</NoBuild>
55
<IncludeBuildOutput>false</IncludeBuildOutput>
66
<NuspecFile>../Octokit.GraphQL.nuspec</NuspecFile>

Octokit.GraphQL.UnitTests/ExpressionRewiterTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public void Repository_Select_Use_Fragment_Twice()
6262
var query = new Query()
6363
.Select(q => new
6464
{
65-
repo1 = q.Repository("foo", "bar").Select(fragment).SingleOrDefault(),
66-
repo2 = q.Repository("foo", "bar").Select(fragment).SingleOrDefault()
65+
repo1 = q.Repository("foo", "bar", null).Select(fragment).SingleOrDefault(),
66+
repo2 = q.Repository("foo", "bar", null).Select(fragment).SingleOrDefault()
6767
});
6868

6969
Expression<Func<JObject, object>> expected = data =>

Octokit.GraphQL.UnitTests/QueryBuilderTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,5 +317,26 @@ ... on User {
317317

318318
Assert.Equal(expected, query.ToString(), ignoreLineEndingDifferences: true);
319319
}
320+
321+
[Fact]
322+
public void DateTimeOffsetVariable()
323+
{
324+
var expected = @"query($start: DateTime) {
325+
user(login: ""grokys"") {
326+
contributionsCollection(from: $start) {
327+
latestRestrictedContributionDate
328+
}
329+
}
330+
}";
331+
332+
var expression = new Query()
333+
.User("grokys")
334+
.ContributionsCollection(@from: Variable.Var("start"))
335+
.Select(c => c.LatestRestrictedContributionDate);
336+
337+
var query = expression.Compile();
338+
339+
Assert.Equal(expected, query.ToString(), ignoreLineEndingDifferences: true);
340+
}
320341
}
321342
}

0 commit comments

Comments
 (0)