refactor: 💡 replace store.findAll with store.query (#2002)

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-11825
This commit is contained in:
Lisbet Alvarez authored and Zhihe Li committed 2024-01-16 10:17:45 -05:00
1 parent 6ae3067dd9
commit 776c46f129
6 files changed
+5 -20

No files matched your search

-10
View File
@@ -106,16 +106,6 @@ export default class ApplicationAdapter extends RESTAdapter.extend(
return dasherize(pluralize(type));
}
/**
* Intercepts "empty" responses and adds an empty `items` array.
* @override
* @method findAll
* @return {Promise} promise
*/
findAll() {
return super.findAll(...arguments).then(prenormalizeArrayResponse);
}
/**
* Intercepts "empty" responses and adds an empty `items` array.
* This query method now supports pagination by checking the responseType and
@@ -12,6 +12,6 @@ export default class ApplicationRoute extends Route {
@service store;
model() {
this.store.findAll('scope');
this.store.query('scope', {});
}
}
@@ -144,12 +144,7 @@ module('Unit | Adapter | application', function (hooks) {
const adapter = this.owner.lookup('adapter:application');
const store = this.owner.lookup('service:store');
this.server.get('/v1/users', () => new Response({}));
const prenormalized = await adapter.findAll(
store,
{ modelName: 'user' },
null,
[],
);
const prenormalized = await adapter.query(store, { modelName: 'user' }, {});
assert.deepEqual(prenormalized, { items: [] });
});
+1 -1
View File
@@ -23,7 +23,7 @@ module('Unit | Model | scope', function (hooks) {
{ id: 'p_3', type: 'project', scope: { scope_id: 'o_2' } },
],
}));
const scopes = await store.findAll('scope');
const scopes = await store.query('scope', {});
// check integrity of scope relationships
assert.notOk(await scopes[0].get('scope'), 'Global scope has no parent');
assert.strictEqual(
+1 -1
View File
@@ -35,7 +35,7 @@ export default class ScopesRoute extends Route {
});
// NOTE: In the absence of a `scope_id` query parameter, this endpoint is
// expected to default to the global scope, thus returning org scopes.
return this.store.findAll('scope').catch(() => A([]));
return this.store.query('scope', {}).catch(() => A([]));
}
/**
+1 -1
View File
@@ -26,6 +26,6 @@ export default class ScopesRoute extends Route {
model() {
// NOTE: In the absence of a `scope_id` query parameter, this endpoint is
// expected to default to the global scope, thus returning org scopes.
return this.store.findAll('scope').catch(() => A([]));
return this.store.query('scope', {}).catch(() => A([]));
}
}