ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.28k stars 748 forks source link

Strawberry Shake: Sequence contains no elements when querying GitHub's GraphQL API for Author #5109

Closed pwyszyns closed 5 months ago

pwyszyns commented 2 years ago

Is there an existing issue for this?

Describe the bug

I'm trying to fetch Pull Requests information from GitHub GraphQL endpoint, however, when I add Author to the query, code generation breaks on build with the error CSC : error SS0006: Sequence contains no elements.

I have tested the same query from Thunder Client (VS code extension for HTTP calls) and it seems to be working fine, fetching the data properly.

Schema can be found here. GraphQL endpoint: https://api.github.com/graphql

The query I'm using is as follows:

query GetRepositoryOpenPullRequests($org: String!, $repositoryName: String!) {
  repository(owner: $org, name: $repositoryName) {
    url
    pullRequests(last: 100, states: OPEN) {
      totalCount
      nodes {
        url
        title
        state
        author {
          login
        }
        commits {
          totalCount
        }
        reviews (last: 100) {
          nodes {
            bodyText
            comments {
              totalCount
            }
            state
          }
        }
      }
    }
  }
}

I'm very new if it comes to GraphQL, so maybe there is an error within the query, but since it works outside of Strawberry Shake, I doubt that.

Steps to reproduce

  1. Create a new project (in my case it's web app, but I don't think it matters much)
  2. Add Strawberry Shake packages and tools as per tutorial
  3. Initialize GraphQL schema
  4. Try to build - build should succeed.
  5. Add above query to project
  6. Try to build again - build will fail with following error: CSC : error SS0006: Sequence contains no elements relating to .csproj file.
  7. Remove author { ... } from the query
  8. Try to build again - build will work.

Relevant log output

CSC : error SS0006: Sequence contains no elements

Additional Context?

I also noticed that the generated file cannot be deleted - it will be re-created in few seconds from deletion. I'm not sure if it's related though.

Product

Strawberry Shake

Version

12.9.0

pwyszyns commented 2 years ago

Hi @michaelstaib I see that you've assigned yourself to this issue some time ago - were you able to reproduce it?

mac2000 commented 2 years ago

Here is an reproduction snippet:

mkdir repro
cd repro
dotnet new web
dotnet add package StrawberryShake.Transport.Http
dotnet add package StrawberryShake.CodeGeneration.CSharp.Analyzers
# dotnet tool install StrawberryShake.Tools --global
dotnet graphql init https://api.github.com/graphql -n GitHubClient --token xxxxxxxxxxxxxxxxxxxx
echo 'query Search($terms: String!) {
  search(type: ISSUE, query: $terms, first: 5) {
    nodes {
      ...on PullRequest {
        title
        author {
          login
        }
      }
    }
  }
}' > Search.graphql
dotnet build

which gives us: CSC : error SS0006: Sequence contains no elements [/repro/repro.csproj]

Or if you wish not to deal with github tokens you can skip step with init and just download schema like so:

wget https://docs.github.com/public/schema.docs.graphql -O schema.graphql

Also observing something similar in octokit graphql but with search in overall rather than author 275

But the query it self seems to be fine and works as expected:

image
glen-84 commented 5 months ago

Closing, as I'm unable to reproduce this error using Strawberry Shake 12.15.3 or 13.9.5.