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

Nested query issue: 'There can be only one argument named "first"' #209

Open
duncanawoods opened this issue Dec 17, 2019 · 2 comments
Open
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

@duncanawoods
Copy link

duncanawoods commented Dec 17, 2019

I'm trying to obtain all issues organised by project and column.

If I execute a query with:

public class ProjectModel
{
    public string Name;
    public string Url;
    public List<ColumnModel> Columns;
}
    
public class ColumnModel
{
    public string Name;
    public List<IssueModel> Issues;
}

public class IssueModel
{
    public string Title;
}

var query = new Query()
    .Repository(repo, owner)
    .Projects()
    .AllPages()
    .Select(
        project => new ProjectModel()
        {
            Name = project.Name,
            Url = project.Url,
            Columns = project
                .Columns(null, null, null, null)
                .AllPages()
                .Select(
                    col => new ColumnModel()
                    {
                        Name = col.Name,
                        Issues = col
                            .Cards(null, null, null, null, null)
                            .AllPages()
                            .Select(
                                projectCard => projectCard
                                    .Content
                                    .Switch<IssueModel>(
                                        when => when
                                            .Issue(
                                                issue => new IssueModel()
                                                {
                                                    Title = issue.Title
                                                })))
                            .ToList()
                    })
                .ToList()
        });

With the query as it stands above, I get the error:

By the time this query traverses to the cards connection, it is requesting up to 1,000,000 possible nodes which exceeds the maximum limit of 500,000.

Which is kind of annoying because it's an insane theoretical maximum. Anyway, if I try to limit the results with e.g. .Columns(10, null, null, null) then I get:

There can be only one argument named "first"

Sorry if I am missing something.

@duncanawoods
Copy link
Author

duncanawoods commented Dec 17, 2019

I have resorted to raw graphql which has no problem with nested first parameters.

var client = new GraphQLHttpClient("https://api.github.com/graphql");

client.DefaultRequestHeaders.Add("Authorization", $"bearer {token}");
client.DefaultRequestHeaders.Add("User-Agent", @"Mozilla/5.0 (Windows NT 10; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0");

var query = @"{
    repository(owner: """ + owner + "\", name: \"" + repo + @""") {
      projects(first: 4) {
        nodes {
          columns(first: 10) {
            nodes {
              name
              cards(first: 100) {
                nodes {
                  content {
                    __typename
                    ... on Issue {
                      title
                      url
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }";

var result = await client.SendQueryAsync(query);

@whitneyschmidt
Copy link

whitneyschmidt commented Jul 28, 2022

I've also run into this issue. If the raw graphql works then there appears to be an issue with the client :(

            var query = new Query()
                .Repository(owner: Var("owner"), name: Var("name"))
                .Select(r => new
                {
                    r.Name,
                    r.Description,
                    PullRequests = r.PullRequests(null, null, null, null, null, null, null, null, null).AllPages().Select(p => new GitHubWorkItem
                    (
                        p.Number,
                        p.Title,
                        p.State) // MERGED, OPEN, or CLOSED)
                    ).ToList(),
                    Issues = r.Issues(50, null, null, null, null, null, null, null).AllPages().Select(i => new GitHubWorkItem
                    (
                        i.Number,
                        i.Title,
                        i.State
                        )// CLOSED or OPEN)

                    ).ToList()
                }).Compile();

@nickfloyd nickfloyd added the bug label Jul 29, 2022
@nickfloyd nickfloyd added Type: Bug Something isn't working as documented and removed bug labels Oct 26, 2022
@nickfloyd nickfloyd added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone labels Nov 7, 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

3 participants