Skip to content

Commit ed3363c

Browse files
committed
04-Apollo Client and a GraphQL Mutation
1 parent a5b1ce6 commit ed3363c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,34 @@ client
8585
})
8686
// log error when there is no next page
8787
.catch(console.log);
88+
89+
const ADD_STAR = gql`
90+
mutation AddStar($repositoryId: ID!) {
91+
addStar(input: { starrableId: $repositoryId }) {
92+
starrable {
93+
id
94+
viewerHasStarred
95+
}
96+
}
97+
}
98+
`;
99+
100+
const REMOVE_STAR = gql`
101+
mutation RemoveStar($repositoryId: ID!) {
102+
removeStar(input: { starrableId: $repositoryId }) {
103+
starrable {
104+
id
105+
viewerHasStarred
106+
}
107+
}
108+
}
109+
`;
110+
111+
client
112+
.mutate({
113+
mutation: ADD_STAR,
114+
variables: {
115+
repositoryId: 'MDEwOlJlcG9zaXRvcnk2MzM1MjkwNw==',
116+
},
117+
})
118+
.then(console.log);

0 commit comments

Comments
 (0)