Data: Feature request: allow users to specify default adapter name

Created on 18 Dec 2018  路  5Comments  路  Source: emberjs/data

In my current project we have model, named application, and also we have default application adapter. And it's kinda legshot.

It will be nice to have config option to specify default adapter name like -application instead of application.

Another option - allow to register adapters for exact model names manually or disallow application model generation in ember-cli

https://github.com/emberjs/data/blob/d48ee83ce8c60a9e6c50faa4c23dcf6c77a7ce45/addon/-private/system/store.js#L3056

Most helpful comment

I''m going to close this as we're working to simplify the adapter lookup logic (see recent RFCs deprecating most fallbacks) and there are clear patterns to use if this edge case is encountered

All 5 comments

We're having the exact same problem in one of our projects.

Can anyone explain the reasoning behind the adapter / serializer fallback logic? I don't understand why the hardcoded :application lookup comes before the configurable lookup (this.adapter and adapter.defaultSerializer).

Can't we remove that :application lookup and set this.adapter and adapter.defaultSerializer to application? I know there probably is a reason it is implemented like this.

@Windvis all of those fallbacks are deprecated.

If you have a model named application I would recommend renaming it to app or user-app or some such and having your serializer convert the inbound/outbound types from/to application to that.

@runspired Oh ok, didn't know they were deprecated. So only the "application" fallback will remain in the future? Does the deprecation also mean that we shouldn't be able to configure the default adapter / serializer, or will this be be implemented in another way?

I'll give renaming the model client side a try. I do think that configuring the serializer / adapter for this model would be a better solution though.

@Windvis generally a single adapter setup will work better, if multiple APIs are in use a delegating adapter (application adapter that simply forwards to an API specific adapter) is a good pattern.

I''m going to close this as we're working to simplify the adapter lookup logic (see recent RFCs deprecating most fallbacks) and there are clear patterns to use if this edge case is encountered

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kennethlarsen picture kennethlarsen  路  3Comments

HenryVonfire picture HenryVonfire  路  3Comments

bartocc picture bartocc  路  4Comments

BryanCrotaz picture BryanCrotaz  路  3Comments

toobulkeh picture toobulkeh  路  3Comments