
WarpDrive is the lightweight data library for web apps —
universal, typed, reactive, and ready to scale.
@ember-data-mirror/serializer
Provides JSON, REST and JSON:API Implementations of the legacy Serializer Interface
Caution ⚠️ This is LEGACY documentation for a feature that is no longer encouraged to be used.
If starting a new app or thinking of implementing a new serializer, consider writing a Handler
instead to be used with the RequestManager
Installation
This package is currently installed when installing ember-data.
If installing @ember-data/ packages individually install using your javascript package manager of choice. For instance with pnpm
pnpm add @ember-data-mirror/serializer
Tagged Releases
🚀 Setup
If using ember-data no additional setup is necesssary.
Note
When using ember-data the below
configuration is handled for you automatically.
To use legacy serializers you will need to have installed and configured the LegacyNetworkHandler from @ember-data-mirror/legacy-compat
pnpm add @ember-data-mirror/legacy-compat
import Store, { CacheHandler } from '@ember-data-mirror/store';
import RequestManager from '@ember-data-mirror/request';
import { LegacyNetworkHandler } from '@ember-data-mirror/legacy-compat';
export default class extends Store {
requestManager = new RequestManager()
.use([LegacyNetworkHandler])
.useCache(CacheHandler);
}
Usage
To use as either a per-type or application serializer, export one of the
implementations within the serializers/ directory of your app as appropriate.
For instance, to configure an application serializer to use JSON:API
app/serializers/application.ts
export { default } from '@ember-data-mirror/serializer/json-api';
By default serializers are resolved by looking for a serializer with the same name in the serializers/ folder as the type given to store.serializerFor(<type>), falling back to looking for a serializer named application.
Overriding Resolution
If you would like to avoid using resolver semantics and your application has only one or a few serializers, you may ovveride the serializerFor hook on the store.
import Store from '@ember-data-mirror/store';
import Serializer from '@ember-data-mirror/serializer/json-api';
class extends Store {
#serializer = new Serializer();
serializerFor() {
return this.#serializer;
}
}
For the full list of APIs available read the code documentation for @ember-data-mirror/serializer. You may also be interested in learning more about EmberData's Serializer Interface.