@@ -13,7 +13,11 @@ const axiosGitHubGraphQL = axios.create({
1313const title = 'React GraphQL GitHub Client' ;
1414
1515const issuesOfRepositoryQuery = `
16- query ($organization: String!, $repository: String!, $cursor: String) {
16+ query (
17+ $organization: String!,
18+ $repository: String!,
19+ $cursor: String
20+ ) {
1721 organization(login: $organization) {
1822 name
1923 url
@@ -81,6 +85,20 @@ const getIssuesOfRepository = (path, cursor) => {
8185 } ) ;
8286} ;
8387
88+ const addStarToRepository = repositoryId => {
89+ return axiosGitHubGraphQL . post ( '' , {
90+ query : addStarToRepositoryMutation ,
91+ variables : { repositoryId } ,
92+ } ) ;
93+ } ;
94+
95+ const removeStarFromRepository = repositoryId => {
96+ return axiosGitHubGraphQL . post ( '' , {
97+ query : removeStarToRepositoryMutation ,
98+ variables : { repositoryId } ,
99+ } ) ;
100+ } ;
101+
84102const resolveIssuesQuery = queryResult => state => {
85103 const oldIssues = state . organization
86104 ? state . organization . repository . issues . edges
@@ -90,35 +108,23 @@ const resolveIssuesQuery = queryResult => state => {
90108 edges : newIssues ,
91109 } = queryResult . data . data . organization . repository . issues ;
92110
111+ const updatedIssues = [ ...oldIssues , ...newIssues ] ;
112+
93113 return {
94114 organization : {
95115 ...queryResult . data . data . organization ,
96116 repository : {
97117 ...queryResult . data . data . organization . repository ,
98118 issues : {
99119 ...queryResult . data . data . organization . repository . issues ,
100- edges : [ ... oldIssues , ... newIssues ] ,
120+ edges : updatedIssues ,
101121 } ,
102122 } ,
103123 } ,
104124 errors : queryResult . data . errors ,
105125 } ;
106126} ;
107127
108- const addStarToRepository = repositoryId => {
109- return axiosGitHubGraphQL . post ( '' , {
110- query : addStarToRepositoryMutation ,
111- variables : { repositoryId } ,
112- } ) ;
113- } ;
114-
115- const removeStarFromRepository = repositoryId => {
116- return axiosGitHubGraphQL . post ( '' , {
117- query : removeStarToRepositoryMutation ,
118- variables : { repositoryId } ,
119- } ) ;
120- } ;
121-
122128const resolveAddStarMutation = mutationResult => state => {
123129 const {
124130 viewerHasStarred,
0 commit comments