Class <Interface> SchemaService
publicThe SchemaService provides the ability to query for information about the structure of any resource type.
Applications can provide any implementation of the SchemaService they please so long as it conforms to this interface.
The design of the service means that schema information could be lazily populated, derived-on-demand, or progressively enhanced during the course of an application's runtime. The primary requirement is merely that any information the service needs to correctly respond to an inquest is available by the time it is asked.
The @ember-data/model
package provides an implementation of this service which
makes use of your model classes as the source of information to respond to queries
about resource schema. While this is useful, this may not be ideal for your application.
For instance, Schema information could be sideloaded or pre-flighted for API calls,
resulting in no need to bundle and ship potentially large and expensive JSON
or large Javascript based Models to pull information from.
To register a custom schema implementation, implement the store's createSchemaService
hook to return an instance of your service.
import Store from '@ember-data/store';
import CustomSchemas from './custom-schemas';
export default class extends Store {
createSchemaService() {
return new CustomSchemas();
}
}
At runtime, both the Store
and the CacheCapabilitiesManager
provide
access to this service via the schema
property.
export default class extends Component {
@service store;
get fields() {
return this.store
.schema
.fields(this.args.dataType);
}
}
Methods
- derivation
- fields
- hasResource
- hasTrait
- hashFn
- registerDerivations
- registerHashFn
- registerResource
- registerResources
- registerTransformations
- resource
- resourceHasTrait
- transformation
Properties
No documented items
Events
No documented items