boztek / ember-data-drupal

Ember data support for Drupal 8 CMS (via JSON API module).
MIT License
11 stars 2 forks source link

api_json parameter missing on query() functions #1

Closed mwienk closed 7 years ago

mwienk commented 7 years ago

The api_json parameter is set in the buildQuery() function of the adapter, however, the query(), queryRecord() and some other functions aren't calling buildQuery().

I have fixed it by adding

  sortQueryParams(obj) {
    if(!obj._format) {
      obj._format = 'api_json';
    }
    return this._super(obj);
  },

However, I'm not sure if that will work correctly. The name of that also function suggests something else, so it might not be the best place. I saw in your TODO file you have looked at the store.query support, did you think of something (better) yet?

boztek commented 7 years ago

I have some ideas and this will be fixed soon.

As it stands store.query works and is where you make "optimised" queries such as using sparse fieldsets, side loading etc. which at the moment means you are on your own for any query parts and you need to use the actual Drupal 8 payload keys rather than the Ember model property name. So before the next version the solution is to include { _format: "api_json" } in the query yourself.

I'm doing some docs first but will work on store.query after that and will solve the _format query problem and the field remapping all in one go I'd say.

boztek commented 7 years ago

This was fixed in 2dcd216. Thanks for reporting @mwienk.