octokit / octokit.graphql.net

A GitHub GraphQL client library for .NET
MIT License
145 stars 49 forks source link

"Must be reducible node" exception with AllPages(). #132

Closed grokys closed 6 years ago

grokys commented 6 years ago

The following query:

new Query()
    .Viewer
    .Select(viewer => new ViewerRepositoriesModel
    {
        Repositories = viewer.Repositories(null, null, null, null, null, order, null, null, null)
            .AllPages()
            .Select(repo => new RepositoryListItemModel
            {
                IsFork = repo.IsFork,
                IsPrivate = repo.IsPrivate,
                Name = repo.Name,
                Owner = repo.Owner.Login,
                Url = new Uri(repo.Url),
            }).ToList(),
        OrganizationRepositories = viewer.Organizations(null, null, null, null).AllPages().Select(org => new
        {
            org.Login,
            Repositories = org.Repositories(null, null, null, null, null, order, null, null, null)
                .AllPages()
                .Select(repo => new RepositoryListItemModel
                {
                    IsFork = repo.IsFork,
                    IsPrivate = repo.IsPrivate,
                    Name = repo.Name,
                    Owner = repo.Owner.Login,
                    Url = new Uri(repo.Url),
                }).ToList()
        }).ToDictionary(x => x.Login, x => (IReadOnlyList<RepositoryListItemModel>)x.Repositories),
    }).Compile();

Throws an exception:

System.ArgumentException
  HResult=0x80070057
  Message=must be reducible node
  Source=System.Core
  StackTrace:
   at System.Linq.Expressions.Expression.ReduceAndCheck()
   at System.Linq.Expressions.Expression.ReduceExtensions()
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExtensionExpression(Expression expr, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
   at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteUnaryExpression(Expression expr, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.MemberAssignmentRewriter..ctor(MemberAssignment binding, StackSpiller spiller, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.BindingRewriter.Create(MemberBinding binding, StackSpiller spiller, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteMemberInitExpression(Expression expr, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpressionFreeTemps(Expression expression, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.Rewrite[T](Expression`1 lambda)
   at System.Linq.Expressions.Expression`1.Accept(StackSpiller spiller)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteLambdaExpression(Expression expr, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
   at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpressionFreeTemps(Expression expression, Stack stack)
   at System.Linq.Expressions.Compiler.StackSpiller.Rewrite[T](Expression`1 lambda)
   at System.Linq.Expressions.Expression`1.Accept(StackSpiller spiller)
   at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
   at System.Linq.Expressions.Expression`1.Compile()
   at Octokit.GraphQL.Core.Builders.ExpressionCompiler.Compile[T](Expression`1 expression)
   at Octokit.GraphQL.Core.SimpleQuery`1..ctor(OperationDefinition operationDefinition, Expression`1 resultBuilder)
   at Octokit.GraphQL.Core.Builders.QueryBuilder.Build[TResult](IQueryableValue`1 query)
   at Octokit.GraphQL.QueryableValueExtensions.Compile[T](IQueryableValue`1 expression)
   at GitHub.Services.RepositoryCloneService.<ReadViewerRepositories>d__8.MoveNext() in D:\projects\github\VisualStudio\src\GitHub.App\Services\RepositoryCloneService.cs:line 68

It seems to be caused by the AllPages() call on Organizations.

grokys commented 6 years ago

This seems to be a case of AllPages() not working with ToDictionary().