@@ -161,7 +161,7 @@ export class RESTTransport implements DataConnectTransport {
161
161
invokeQuery : < T , U > (
162
162
queryName : string ,
163
163
body ?: U
164
- ) => PromiseLike < { data : T ; errors : Error [ ] } > = < T , U = unknown > (
164
+ ) => Promise < { data : T ; errors : Error [ ] } > = < T , U = unknown > (
165
165
queryName : string ,
166
166
body : U
167
167
) => {
@@ -183,9 +183,22 @@ export class RESTTransport implements DataConnectTransport {
183
183
)
184
184
) ;
185
185
186
+ // QUESTION:
187
+ // my understanding is that the code below does the following:
188
+ // - return an object with properties which are methods (the same methods required for Promise, plus one more, "cancel")
189
+ // - each of these methods should be bound to the corresponding method from the withAuth promise
190
+ // - why not just return withAuth? is this so we can add the "cancel" method in there?
191
+ // ANOTHER QUESTION:
192
+ // - do we want queries to be cancellable? there was no "cancel" method written here, i added it
186
193
return {
187
194
then : withAuth . then . bind ( withAuth ) ,
188
- catch : withAuth . catch . bind ( withAuth )
195
+ catch : withAuth . catch . bind ( withAuth ) ,
196
+ finally : withAuth . finally . bind ( withAuth ) ,
197
+ cancel : ( ) => abortController . abort ( ) ,
198
+ get [ Symbol . toStringTag ] ( ) {
199
+ return 'Promise' ;
200
+ }
201
+
189
202
} ;
190
203
} ;
191
204
invokeMutation : < T , U > (
@@ -213,8 +226,8 @@ export class RESTTransport implements DataConnectTransport {
213
226
} ) ;
214
227
215
228
216
- // QUESTIONS :
217
- // 1) my understanding is that the code below does the following:
229
+ // QUESTION :
230
+ // my understanding is that the code below does the following:
218
231
// - return an object with properties which are methods (the same methods required for Promise, plus one more, "cancel")
219
232
// - each of these methods should be bound to the corresponding method from the taskResult promise
220
233
// - why not just return taskResult? is this so we can add the "cancel" method in there?
0 commit comments