import {gql} from '@apollo/client';
export const PULL_REQUESTS_QUERY = gql`
query PullRequestsQuery($query: String!, $after: String) {
search(query: $query, type: REPOSITORY, first: 100, after: $after) {
repositoryCount
nodes {
... on Repository {
nameWithOwner
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
`;
So here’s a pull request query for GitHub’s API.
This will return a response like…
{
"search": {
"nodes": [
{
"nameWithOwner": ''NAME_WITH_OWNER"
}
]
// ...
}
}
For my React components, I’d like to transform the structure to something like…
{
"repositories": [
{
"nameWithOwner": ''NAME_WITH_OWNER"
}
]
}
All I do is read the data and I don’t mutate or anything. That’s the best way to way with Apollo client?