A client-side server to build, test and share your JavaScript app
🚀 Enhancements
🏠 Internal
🐛 Bugfixes
🏠 Internal
🚀 Enhancements
🏠 Internal
Upgrade to Pretender 3.4.0
Dependency updates
🚀 Enhancements
#328 Make serializer.schema
public
A reference to the schema instance. Useful to reference registered schema information.
#325 Relationship introspection
This is a new feature that allows you to introspect a model's associations.
Given
import { Server, Model, hasMany, belongsTo }
new Server({
models: {
user: Model,
post: Model.extend({
user: belongsTo(),
comments: hasMany()
}),
comments: Model
}
})
you can now introspect the post's associations, either through schema
or an actual instance of the Post model:
server.schema.associationsFor('post')
// or
post.associations
Both methods will return the same data structure:
{
user: BelongsToAssociation,
comments: HasManyAssociation
}
and you can use the new properties exposed on the Association class to get the type, name, modelName, and foreign key:
let userAssociation = post.associations.user
userAssociation.type // "belongsTo"
userAssociation.name // "user"
userAssociation.modelName // "user"
userAssociation.foreignKey // "userId"
This feature can be useful if you need to build up something dynamically based on a model's relationships.
#327 Pass the primary resource to serializer.include()
This is an update to the Serializer.include
method that lets you use the primary resource being serialized to determine what the included associations should be.
For example, when combined with the previous feature, you can use it to configure your Serializer to include all of a model's relationships by default:
new Server({
serializers: {
application: Serializer.extend({
include(request, resource) {
let associations = this.schema.associationsFor(resource.modelName);
return Object.keys(associations)
}
})
}
})
🏠 Internal
🐛 Bugfixes
📝 Docs
🏠 Internal
🐛 Bugfixes
📝 Docs
baseConfig
to routes
in docs.🏠 Internal
🚀 Enhancements
🐛 Bugfixes
📝 Docs
🏠 Internal
🚀 Enhancements
@miragejs/server
references to miragejs
🚀 Enhancements
This release updates the npm package name from from @miragejs/server
to miragejs
.
If you're using @miragejs/server
directly in your project, swap it out for the latest 0.1.x
version of miragejs
and change all import paths from "@miragejs/server"
to "miragejs"
.
If you're using ember-cli-mirage
, you can upgrade to v1.1.4
or later to address this deprecation.
🚀 Enhancements
🏡 Internal