@@ -133,6 +133,18 @@ const RepositoryItem = ({
133133 ? VIEWER_SUBSCRIPTIONS . UNSUBSCRIBED
134134 : VIEWER_SUBSCRIPTIONS . SUBSCRIBED ,
135135 } }
136+ optimisticResponse = { {
137+ updateSubscription : {
138+ __typename : 'Mutation' ,
139+ subscribable : {
140+ __typename : 'Repository' ,
141+ id,
142+ viewerSubscription : isWatch ( viewerSubscription )
143+ ? VIEWER_SUBSCRIPTIONS . UNSUBSCRIBED
144+ : VIEWER_SUBSCRIPTIONS . SUBSCRIBED ,
145+ } ,
146+ } ,
147+ } }
136148 update = { updateWatch }
137149 >
138150 { ( updateSubscription , { data, loading, error } ) => (
@@ -151,6 +163,16 @@ const RepositoryItem = ({
151163 < Mutation
152164 mutation = { STAR_REPOSITORY }
153165 variables = { { id } }
166+ optimisticResponse = { {
167+ addStar : {
168+ __typename : 'Mutation' ,
169+ starrable : {
170+ __typename : 'Repository' ,
171+ id,
172+ viewerHasStarred : ! viewerHasStarred ,
173+ } ,
174+ } ,
175+ } }
154176 update = { updateAddStar }
155177 >
156178 { ( addStar , { data, loading, error } ) => (
@@ -166,6 +188,16 @@ const RepositoryItem = ({
166188 < Mutation
167189 mutation = { UNSTAR_REPOSITORY }
168190 variables = { { id } }
191+ optimisticResponse = { {
192+ removeStar : {
193+ __typename : 'Mutation' ,
194+ starrable : {
195+ __typename : 'Repository' ,
196+ id,
197+ viewerHasStarred : ! viewerHasStarred ,
198+ } ,
199+ } ,
200+ } }
169201 update = { updateRemoveStar }
170202 >
171203 { ( removeStar , { data, loading, error } ) => (
0 commit comments