data icon indicating copy to clipboard operation
data copied to clipboard

Include param should always reference array in docs

Open Baltazore opened this issue 1 year ago • 3 comments

Due to confusion described in https://github.com/emberjs/data/issues/9502 we should update docs and maybe internal usage

TODO:

  • [ ] Add lint rule with autofix
  • [ ] Verify all docs updated
  • [ ] Verify guides updated https://github.com/ember-learn/guides-source/pull/2048

Baltazore avatar Jul 09 '24 09:07 Baltazore

In you checklist we need to add one point, that we need todo, before we ship lint, updating docs... otherwise api isn't working correctly with includes, when users are using legacy code-parts.

Atm all legacy codes like this.store.findAll / this.store.findRecord are passing include not correctly to api.

When we pass a string[] to include (include: ['comments', 'author']) the urls is: api/post?include[]=comments&include[]=author

Correctly is: api/post?include=comments,author

This fix we should also ship to LTS versions, because the current lts are making this mistake

mkszepp avatar Jul 09 '24 21:07 mkszepp

@mkszepp as I said in the ticket, we'd need to look at your particular setup to determine why that is, as that's up to the adapter to do

runspired avatar Jul 09 '24 23:07 runspired

@mkszepp as I said in the ticket, we'd need to look at your particular setup to determine why that is, as that's up to the adapter to do

its not my stetup directly... the bug is already with default json-api adapter (like already told in issue)... here the repo with incorrect api call https://github.com/mkszepp/ember-data-ts-errors/commit/152a1055c53978644e3c8c99c42a24ab701c5223)

grafik

Edit: I think the problem is this code part... https://github.com/emberjs/data/blob/3ec0359017d321d43d914f4fffda51c0672f58b5/packages/adapter/src/-private/utils/serialize-query-params.ts#L35

for json-api its always correct when its not include as string[], but this code part will be used inside rest-adapter (see https://github.com/emberjs/data/blob/main/packages/adapter/src/rest.ts#L1466), so we need any override inside json-api adapter to fix this

Should we create an additional issue for this bug or do we handel this with my initial issue? Because its not directly part of this PR (only related).

I just wanted to point out in this PR that some other fixes are necessary before we merge this (as it is missing in todo list), because you can't force in docs... to use string[] when its not working with legacy adapter.

mkszepp avatar Jul 10 '24 05:07 mkszepp