amplifyquery 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/service.js +7 -1
- package/package.json +1 -1
package/dist/service.js
CHANGED
|
@@ -487,7 +487,13 @@ function createAmplifyService(modelName, defaultAuthMode) {
|
|
|
487
487
|
// Get parameters based on auth mode
|
|
488
488
|
const { authModeParams } = yield getOwnerByAuthMode(authMode);
|
|
489
489
|
// API call - apply auth mode
|
|
490
|
-
const { data:
|
|
490
|
+
const { data: apiResponse } = yield (0, client_1.getClient)().models[modelName].get({ id }, authModeParams);
|
|
491
|
+
// Handle case where API returns array instead of single item
|
|
492
|
+
let item = apiResponse;
|
|
493
|
+
if (Array.isArray(apiResponse)) {
|
|
494
|
+
console.warn(`🍬 ${modelName} get: API returned array instead of single item. Taking first item.`);
|
|
495
|
+
item = apiResponse.find((i) => (i === null || i === void 0 ? void 0 : i.id) === id) || apiResponse[0] || null;
|
|
496
|
+
}
|
|
491
497
|
// Update cache
|
|
492
498
|
if (item) {
|
|
493
499
|
const itemId = item === null || item === void 0 ? void 0 : item.id;
|