Search code examples
ember.jsember-datajson-apijsonapi-resources

How to sideload {json:api} records with Ember Data 2 and JSONAPI::Resources in Rails?


I'm developing an Ember app with a Rails backend, using the excellent JSONAPI::Resources gem to expose my data.

I'd like to fetch records from my the backend using store.findRecord, store.query, etc. while sideloading certain relationships. JSONAPI::Resources supports this part of the spec but I can't figure out how to make Ember Data include the ?include=... parameter in the request URL.

How can I instruct Ember Data (2.2.0) to ask the backend to include relationships when fetching resources?


Solution

  • If you are able, you can try out the Ember Data 2.4 beta, which includes the ds-finder-include feature flag.

    This feature flag enables you to pass an options hash with an includes key.

    To learn how to enable feature flags check the guide.