Skip to content

Commit 83f794c

Browse files
committed
passing variables with our graphQL Query
1 parent 9692e0f commit 83f794c

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/App.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ const GET_REPOSITORY_OF_ORGANIZATION = `
3535
`;
3636

3737
const GET_ISSUES_OF_REPOSITORY = `
38-
{
39-
organization(login: "the-road-to-learn-react") {
40-
name
41-
url
42-
repository(name: "the-road-to-learn-react") {
38+
query($organization: String!, $repository: String!) {
39+
organization(login: $organization) {
4340
name
4441
url
45-
issues( last: 5 ) {
46-
edges {
47-
node {
48-
id
49-
title
50-
url
42+
repository(name: $repository) {
43+
name
44+
url
45+
issues( last: 5 ) {
46+
edges {
47+
node {
48+
id
49+
title
50+
url
51+
}
5152
}
5253
}
5354
}
5455
}
5556
}
56-
}
57-
`;
57+
`;
5858

5959
const getIssuesOfRepositoryQuery = (organization, repository) => `{
6060
organization( login: "${organization}") {
@@ -80,7 +80,8 @@ const getIssuesOfRepository = path => {
8080
const [organization, repository] = path.split('/');
8181

8282
return axiosGithubGraphQL.post('', {
83-
query: getIssuesOfRepositoryQuery(organization, repository),
83+
query: GET_ISSUES_OF_REPOSITORY,
84+
variables: { organization, repository },
8485
});
8586
};
8687

0 commit comments

Comments
 (0)