graphql-platform
graphql-platform copied to clipboard
Strawberry Shake: Sequence contains no elements when querying GitHub's GraphQL API for Author
Is there an existing issue for this?
- [X] I have searched the existing issues
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
- Create a new project (in my case it's web app, but I don't think it matters much)
- Add Strawberry Shake packages and tools as per tutorial
- Initialize GraphQL schema
- Try to build - build should succeed.
- Add above query to project
- Try to build again - build will fail with following error:
CSC : error SS0006: Sequence contains no elementsrelating to .csproj file. - Remove
author { ... }from the query - 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
Hi @michaelstaib I see that you've assigned yourself to this issue some time ago - were you able to reproduce it?
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: