|
1 | 1 | using System;
|
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using Octokit.GraphQL.Core; |
2 | 5 | using Octokit.GraphQL.Model;
|
3 | 6 | using Xunit;
|
4 | 7 |
|
@@ -117,7 +120,7 @@ public void RepositoryOwner_Repositories_Query_Viewer()
|
117 | 120 | var expression = new Query()
|
118 | 121 | .Select(root => root
|
119 | 122 | .RepositoryOwner("foo")
|
120 |
| - .Repositories(30, null, null, null, null, null, null, null, null, null) |
| 123 | + .Repositories(30, null, null, null, null, null, null, null, null, null, null) |
121 | 124 | .Edges.Select(x => x.Node)
|
122 | 125 | .Select(x => new
|
123 | 126 | {
|
@@ -218,7 +221,7 @@ public void Repository_Details_With_Viewer()
|
218 | 221 |
|
219 | 222 | var expression = new Query()
|
220 | 223 | .Select(x => x.RepositoryOwner("foo")
|
221 |
| - .Repositories(30, null, null, null, null, null, null, null, null, null) |
| 224 | + .Repositories(30, null, null, null, null, null, null, null, null, null, null) |
222 | 225 | .Edges
|
223 | 226 | .Select(y => y.Node)
|
224 | 227 | .Select(y => new
|
@@ -338,5 +341,58 @@ public void DateTimeOffsetVariable()
|
338 | 341 |
|
339 | 342 | Assert.Equal(expected, query.ToString(), ignoreLineEndingDifferences: true);
|
340 | 343 | }
|
| 344 | + |
| 345 | + |
| 346 | + [Fact] |
| 347 | + public void TestAllPagesSubqueryUsesCorrectEntityName() |
| 348 | + { |
| 349 | + var expectedMasterQuery = @"query { |
| 350 | + repositoryOwner(login: ""foo"") { |
| 351 | + id |
| 352 | + repositories(first: 100) { |
| 353 | + pageInfo { |
| 354 | + hasNextPage |
| 355 | + endCursor |
| 356 | + } |
| 357 | + nodes { |
| 358 | + name |
| 359 | + } |
| 360 | + } |
| 361 | + } |
| 362 | +}"; |
| 363 | + |
| 364 | + // The actual type that we map RepositoryOwner to is called StubIRepositoryOwner |
| 365 | + // So make sure it gets serialized to the query correctly. |
| 366 | + var expectedSubQuery = @"query($__id: ID!, $__after: String) { |
| 367 | + node(id: $__id) { |
| 368 | + __typename |
| 369 | + ... on RepositoryOwner { |
| 370 | + repositories(first: 100, after: $__after) { |
| 371 | + pageInfo { |
| 372 | + hasNextPage |
| 373 | + endCursor |
| 374 | + } |
| 375 | + nodes { |
| 376 | + name |
| 377 | + } |
| 378 | + } |
| 379 | + } |
| 380 | + } |
| 381 | +}"; |
| 382 | + |
| 383 | + var query = new Query() |
| 384 | + .RepositoryOwner("foo") |
| 385 | + .Repositories() |
| 386 | + .AllPages(100) |
| 387 | + .Select(x => x.Name) |
| 388 | + .Compile(); |
| 389 | + |
| 390 | + var subQuery = (query as PagedQuery<IEnumerable<string>>).Subqueries.First(); |
| 391 | + |
| 392 | + Assert.Equal(expectedMasterQuery, query.ToString(), ignoreLineEndingDifferences: true); |
| 393 | + Assert.Equal(expectedSubQuery, subQuery.ToString(), ignoreLineEndingDifferences: true); |
| 394 | + |
| 395 | + |
| 396 | + } |
341 | 397 | }
|
342 | 398 | }
|
0 commit comments