« All deprecation guides

Deprecation Guide for Deprecate Early Static

until: 5.0
id: ember-data:deprecate-early-static

This deprecation triggers if static computed properties or methods are triggered without looking up the record via the store service's modelFor hook. Accessing this static information without looking up the model via the store most commonly occurs when:

  • using ember-cli-mirage (to fix, refactor to not use its auto-discovery of ember-data models)
  • importing a model class and accessing its static information via the import

Instead of:

import User from 'my-app/models/user';

const relationships = User.relationshipsByName;

Do at least this:

const relationships = store.modelFor('user').relationshipsByName;

However, the much more future proof refactor is to not use modelFor at all, but instead to utilize the schema service for this static information:

const relationships = store
  .getSchemaDefinitionService()
  .relationshipsDefinitionFor({ type: 'user' });