[5.3.9] Builded url for `this.store.query` incorrect when passing `include` as array
The this.store.query (legacy adapters) isn't working correctly when we pass includes as array.
this.store.query<Company>('company', {
filter: {
type: 'example',
},
include: ['ceo', 'employee'],
});
The query params result in url is: &include[]=ceo&include[]=employee
it should be &include=ceo,employee
This bug was fixed for findAll & findRecord in #9583
It was not fixed for query (maybe also other) because this.buildQuery will not be called inside that function
https://github.com/emberjs/data/blob/83c176c2b561bea98616015fb9b643ccf0f5e4da/packages/adapter/src/rest.ts#L587-L595
I have the same issue, where I need the query url formatted like &include=ceo,employee
Giving it as string for now so that it continues to work against the API as it is written, but then I need to ignore type issues.
@Techn1x just as tip... we have also initial hold as string in TS project, but removing all eslint disabled... were again so much work At the end we have created a override in our apps in application adapter
// Fix for reported issue https://github.com/emberjs/data/issues/9588
override query(store: Store, type: ModelSchema, query: Record<string, unknown>): Promise<AdapterPayload> {
if (query) {
const { include } = query;
const normalizedInclude = Array.isArray(include) ? include.join(',') : include;
if (normalizedInclude) {
query['include'] = normalizedInclude;
}
}
return super.query(store, type, query);
}