GraphQL Nested Objects in React

Learn to request a nested object for the Organization

We'll cover the following...

In this lesson, we will request a nested object for the organization. Since the application will eventually show the issues in a repository, we will fetch a repository of an organization as the next step.

Remember, a query reaches into the GraphQL graph. So we can nest the repository field in the organization when the schema defines the relationship between these two entities.

Press + to interact
const GET_REPOSITORY_OF_ORGANIZATION = `
{
organization(login: "the-road-to-learn-react") {
name
url
repository(name: "the-road-to-learn-react") {
name
url
}
}
}
`;
class App extends Component {
...
onFetchFromGitHub = () => {
axiosGitHubGraphQL
.post('', { query: GET_REPOSITORY_OF_ORGANIZATION })
.then(result =>
...
);
};
...
}
...