@@ -15,6 +15,8 @@ import 'package:amplify_api_dart/src/util/amplify_api_config.dart';
15
15
import 'package:amplify_api_dart/src/util/amplify_authorization_rest_client.dart' ;
16
16
import 'package:amplify_core/amplify_core.dart' ;
17
17
// ignore: implementation_imports
18
+ import 'package:amplify_core/src/config/amplify_outputs/api_outputs.dart' ;
19
+ // ignore: implementation_imports
18
20
import 'package:amplify_core/src/config/amplify_outputs/data/data_outputs.dart' ;
19
21
// ignore: implementation_imports
20
22
import 'package:amplify_core/src/config/amplify_outputs/rest_api/rest_api_outputs.dart' ;
@@ -162,7 +164,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
162
164
/// Use [apiName] if there are multiple endpoints of the same type.
163
165
@visibleForTesting
164
166
AWSHttpClient getHttpClient (
165
- EndpointType type, {
167
+ ApiType type, {
166
168
String ? apiName,
167
169
APIAuthorizationType ? authorizationMode,
168
170
}) {
@@ -181,8 +183,8 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
181
183
);
182
184
}
183
185
184
- EndpointConfig _getEndpointConfig (EndpointType type, String ? apiName) {
185
- if (type == EndpointType .graphQL) {
186
+ EndpointConfig _getEndpointConfig (ApiType type, String ? apiName) {
187
+ if (type == ApiType .graphQL) {
186
188
if (_dataConfig == null ) {
187
189
throw ConfigurationError (
188
190
'No GraphQL API endpoint found.' ,
@@ -210,16 +212,10 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
210
212
}
211
213
return EndpointConfig (
212
214
apiName,
213
- AWSApiConfig (
214
- region: config.awsRegion,
215
- endpoint: config.url,
216
- endpointType: EndpointType .graphQL,
217
- authorizationType: config.defaultAuthorizationType,
218
- apiKey: config.apiKey,
219
- ),
215
+ config,
220
216
);
221
217
}
222
- if (type == EndpointType .rest) {
218
+ if (type == ApiType .rest) {
223
219
if (_restConfig == null ) {
224
220
throw ConfigurationError (
225
221
'No REST API endpoint found.' ,
@@ -247,13 +243,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
247
243
}
248
244
return EndpointConfig (
249
245
apiName,
250
- AWSApiConfig (
251
- region: config.awsRegion,
252
- endpoint: config.url,
253
- endpointType: EndpointType .rest,
254
- authorizationType: config.authorizationType,
255
- apiKey: config.apiKey,
256
- ),
246
+ config,
257
247
);
258
248
}
259
249
throw ConfigurationError (
@@ -263,7 +253,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
263
253
264
254
WebSocketBloc _webSocketBloc ({String ? apiName}) {
265
255
final endpoint = _getEndpointConfig (
266
- EndpointType .graphQL,
256
+ ApiType .graphQL,
267
257
apiName,
268
258
);
269
259
@@ -292,7 +282,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
292
282
293
283
Uri _getGraphQLUri (String ? apiName) {
294
284
final endpoint = _getEndpointConfig (
295
- EndpointType .graphQL,
285
+ ApiType .graphQL,
296
286
apiName,
297
287
);
298
288
return endpoint.getUri ();
@@ -304,7 +294,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
304
294
Map <String , dynamic >? queryParameters,
305
295
) {
306
296
final endpoint = _getEndpointConfig (
307
- EndpointType .rest,
297
+ ApiType .rest,
308
298
apiName,
309
299
);
310
300
return endpoint.getUri (path: path, queryParameters: queryParameters);
@@ -317,7 +307,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
317
307
@override
318
308
GraphQLOperation <T > query <T >({required GraphQLRequest <T > request}) {
319
309
final graphQLClient = getHttpClient (
320
- EndpointType .graphQL,
310
+ ApiType .graphQL,
321
311
apiName: request.apiName,
322
312
authorizationMode: request.authorizationMode,
323
313
);
@@ -333,7 +323,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
333
323
@override
334
324
GraphQLOperation <T > mutate <T >({required GraphQLRequest <T > request}) {
335
325
final graphQLClient = getHttpClient (
336
- EndpointType .graphQL,
326
+ ApiType .graphQL,
337
327
apiName: request.apiName,
338
328
authorizationMode: request.authorizationMode,
339
329
);
@@ -366,7 +356,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
366
356
String ? apiName,
367
357
}) {
368
358
final uri = _getRestUri (path, apiName, queryParameters);
369
- final client = getHttpClient (EndpointType .rest, apiName: apiName);
359
+ final client = getHttpClient (ApiType .rest, apiName: apiName);
370
360
return RestOperation .fromHttpOperation (
371
361
AWSStreamedHttpRequest .delete (
372
362
uri,
@@ -384,7 +374,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
384
374
String ? apiName,
385
375
}) {
386
376
final uri = _getRestUri (path, apiName, queryParameters);
387
- final client = getHttpClient (EndpointType .rest, apiName: apiName);
377
+ final client = getHttpClient (ApiType .rest, apiName: apiName);
388
378
return RestOperation .fromHttpOperation (
389
379
AWSHttpRequest .get (
390
380
uri,
@@ -401,7 +391,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
401
391
String ? apiName,
402
392
}) {
403
393
final uri = _getRestUri (path, apiName, queryParameters);
404
- final client = getHttpClient (EndpointType .rest, apiName: apiName);
394
+ final client = getHttpClient (ApiType .rest, apiName: apiName);
405
395
return RestOperation .fromHttpOperation (
406
396
AWSHttpRequest .head (
407
397
uri,
@@ -419,7 +409,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
419
409
String ? apiName,
420
410
}) {
421
411
final uri = _getRestUri (path, apiName, queryParameters);
422
- final client = getHttpClient (EndpointType .rest, apiName: apiName);
412
+ final client = getHttpClient (ApiType .rest, apiName: apiName);
423
413
return RestOperation .fromHttpOperation (
424
414
AWSStreamedHttpRequest .patch (
425
415
uri,
@@ -438,7 +428,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
438
428
String ? apiName,
439
429
}) {
440
430
final uri = _getRestUri (path, apiName, queryParameters);
441
- final client = getHttpClient (EndpointType .rest, apiName: apiName);
431
+ final client = getHttpClient (ApiType .rest, apiName: apiName);
442
432
return RestOperation .fromHttpOperation (
443
433
AWSStreamedHttpRequest .post (
444
434
uri,
@@ -457,7 +447,7 @@ class AmplifyAPIDart extends APIPluginInterface with AWSDebuggable {
457
447
String ? apiName,
458
448
}) {
459
449
final uri = _getRestUri (path, apiName, queryParameters);
460
- final client = getHttpClient (EndpointType .rest, apiName: apiName);
450
+ final client = getHttpClient (ApiType .rest, apiName: apiName);
461
451
return RestOperation .fromHttpOperation (
462
452
AWSStreamedHttpRequest .put (
463
453
uri,
0 commit comments