Skip to content

Commit 71a9c23

Browse files
committed
update for using variables insead of string interpolation
1 parent b999090 commit 71a9c23

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/App.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const axiosGitHubGraphQL = axios.create({
1212

1313
const title = 'React GraphQL GitHub Client';
1414

15-
const getIssuesOfRepositoryQuery = (organization, repository) => `
16-
{
17-
organization(login: "${organization}") {
15+
const issuesOfRepositoryQuery = `
16+
query ($organization: String!, $repository: String!) {
17+
organization(login: $organization) {
1818
name
1919
url
20-
repository(name: "${repository}") {
20+
repository(name: $repository) {
2121
name
2222
url
2323
issues(last: 5, states: [OPEN]) {
@@ -43,9 +43,9 @@ const getIssuesOfRepositoryQuery = (organization, repository) => `
4343
}
4444
`;
4545

46-
const getAddReactionToIssueMutation = issueId => `
47-
mutation {
48-
addReaction(input:{subjectId:"${issueId}",content:HOORAY}) {
46+
const addReactionToIssueMutation = `
47+
mutation ($issueId: ID!) {
48+
addReaction(input:{subjectId:$issueId,content:HOORAY}) {
4949
reaction {
5050
content
5151
}
@@ -58,15 +58,17 @@ const getAddReactionToIssueMutation = issueId => `
5858

5959
const addReactionToIssue = issueId => {
6060
return axiosGitHubGraphQL.post('', {
61-
query: getAddReactionToIssueMutation(issueId),
61+
query: addReactionToIssueMutation,
62+
variables: { issueId },
6263
});
6364
};
6465

6566
const getIssuesOfRepository = path => {
6667
const [organization, repository] = path.split('/');
6768

6869
return axiosGitHubGraphQL.post('', {
69-
query: getIssuesOfRepositoryQuery(organization, repository),
70+
query: issuesOfRepositoryQuery,
71+
variables: { organization, repository },
7072
});
7173
};
7274

0 commit comments

Comments
 (0)