Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Sequence contains no elements" exception is thrown when trying to call AllPages on a Search connection #275

Open
mac2000 opened this issue Sep 3, 2022 · 0 comments
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@mac2000
Copy link

mac2000 commented Sep 3, 2022

problem

Following example:

var query = new Query()
    .Search("is:pr is:open org:whatever", SearchType.Issue)
    .AllPages()
    .Select(r => r.Switch<object>(when => when.PullRequest(p => new { p.Title })))
    .Compile();
Console.WriteLine(query);

fails in runtime with following exception:

Unhandled exception. System.InvalidOperationException: Sequence contains no elements
Unhandled exception. System.InvalidOperationException: Sequence contains no elements
   at System.Linq.ThrowHelper.ThrowNoElementsException()
   at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source)
   at Octokit.GraphQL.Core.Builders.QueryBuilder.RewriteListExtension(MethodCallExpression expression, MemberInfo alias)
   at Octokit.GraphQL.Core.Builders.QueryBuilder.VisitMethodCall(MethodCallExpression node, MemberInfo alias)
   at Octokit.GraphQL.Core.Builders.QueryBuilder.VisitMethodCall(MethodCallExpression node)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at Octokit.GraphQL.Core.Builders.QueryBuilder.Build[TResult](IQueryableList`1 query)
   at Octokit.GraphQL.QueryableListExtensions.Compile[T](IQueryableList`1 expression)
   at Program.<Main>$(String[] args) in /Users/mac/Desktop/octographdotnet/Program.cs:line 26

if I replace .AllPages() with .Nodes then it compiles into something like:

query {
  search(query: "is:pr is:open org:whatever", type: ISSUE) {
    nodes {
      __typename
      ... on PullRequest {
        title
      }
    }
  }
}

expected

Expecting it to behave similar to something like this one:

var query = new Query()
    .Organization("whatever")
    .Repositories()
    .AllPages()
    .Select(r => r.Name)
    .Compile();
Console.WriteLine(query);

with such output

query {
  organization(login: "whatever") {
    id
    repositories(first: 100) {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        name
      }
    }
  }
}

Also not sure if that's relate, but observing something similar with dotnet strawberry shake client here

@nickfloyd nickfloyd added Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented and removed up-for-grabs labels Oct 26, 2022
@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

2 participants