First of all, thanks to @rwieruch for the course!
I'm trying out the exercises at the end of the Apollo Client with Pagination, Variables, Nested
Objects and List Fields chapter, and have encountered a problem querying the GitHub API where the orderBy argument appears to be ignored.
Query:
query ($organization: String!) {
organization(login: $organization) {
name
url
repositories(first: 5, orderBy: {field: STARGAZERS, direction: DESC}) {
edges {
node {
name
url
stargazers {
totalCount
}
}
}
}
}
}
Variables:
{
"organization": "the-road-to-learn-react"
}
Response:
{
"data": {
"organization": {
"name": "The Road to learn React",
"url": "https://github.com/the-road-to-learn-react",
"repositories": {
"edges": [
{
"node": {
"name": "react-lift-state",
"url": "https://github.com/the-road-to-learn-react/react-lift-state",
"stargazers": {
"totalCount": 0
}
}
},
{
"node": {
"name": "use-with-viewbox",
"url": "https://github.com/the-road-to-learn-react/use-with-viewbox",
"stargazers": {
"totalCount": 1
}
}
},
{
"node": {
"name": "the-road-to-learn-react-albanian",
"url": "https://github.com/the-road-to-learn-react/the-road-to-learn-react-albanian",
"stargazers": {
"totalCount": 1
}
}
},
{
"node": {
"name": "react-router-nested-routes-example",
"url": "https://github.com/the-road-to-learn-react/react-router-nested-routes-example",
"stargazers": {
"totalCount": 2
}
}
},
{
"node": {
"name": "react-usereducer-hook",
"url": "https://github.com/the-road-to-learn-react/react-usereducer-hook",
"stargazers": {
"totalCount": 3
}
}
}
]
}
}
}
}
The results are always returned in ascending order no matter what direction is passed in. I have also tried cloning this repo, and adding in some additional console.log output I can see that the same thing happens.
I have tried checking the documentation in graphiql and the query appears to be correct so it may actually be an issue with the API itself, just thought I would point it out in case anyone else encounters this same issue and finds it confusing!