So I currently have a Spring back end and I am basically giving up on trying to make it work with Ember Data. The problem is the JSON formatting of course. What is THE backend that everyone is using with Ember Data? I just want something that will work so I can get started with my development, and not spending a lot of time researching how to fix something. It appears to me that people are using Ruby. Does Ruby support the JSONApi format? If not, what IS everyone using?
However, if you already have a backend ready, why not try an alternative data store for your Ember app? One that looks very nice is SoftLayer Ember Store. The SoftLayer guys developed it for their legacy API, and it’s pretty flexible; however, it lacks relationship management.
If you go the Ruby on Rails route, I’d advise using the 0.8.x branch of Active Model Serializers in your Rails project and the ActiveModelSerializer adapter in your Ember project. Also avoid nested routes even though they can make sense and are easy in Rails, they won’t play well with Ember Data (for now).
My backend is Rails. I began with ActiveModelSerializers but found that modifying it was difficult. I settled on https://github.com/ismasan/oat which supports JSON-API pretty well. I’ve had to make customizations for polymorphism, inheritance, and to prevent circular references on my fork.
I’ve integrated a Spring backend with Ember Data recently for a client’s project and I can attest that it’s quite a chore to get running. You cannot just take an object graph and serialize it the way you do with a regular Spring MVC controller.
The major pain point using Ember Data with a Java/Spring backend is that every object must have an identity, even nested submodels. This is quite an unusual requirement if you’re working with, for example, JPA. To get around this you have to make customizations in the Jackson JSON mapping using annotations.
If you already have a Spring backend, evaluating simpler alternatives to Ember Data might be worth the effort:
We are using SailsJs with ember-blueprints - absolutely loving it! Was using a .NET backend but TBH I’ve gone right off .NET these days lol - the dev cycle is just too horrendously slow with very little gains - if any!
The code shows the Jackson annotations needed to map the output to Ember Data-compliant format.
Use of @JsonIdentifyInfo illustrates the need for embedded objects to have separate identity:
The only relevant thing here is the serializer:
This example has a very simple domain model, but already illustrates the many pain points you’ll encounter. Without framework-level support for Ember Data integration, you’ll be stuck in boilerplate hell before you’re even getting started.
I think the lowest overhead way to get it done is to use Express and
something like Mongo. Since NoSQL data stores don’t really make any
assumptions about your models, you can store what Ember Data sends as-is,
and with Express, you can handle server routing right in the app. You can
do simple endpoints in 3 or 4 lines of boilerplate. Just override ED’s
serializer to use _id as the primary key and you’re set.
My preference is using the Django REST Framework with a server side compatibility adapter (full disclosure: I’m one of the authors of the adapter) that makes the server use the same format as Ember Data expects. The adapter also handles snake_case to camelCase conversion and pluralization so you can use different variable name styles in each environment.
While it may take a little to learn how Ember Data works once you do it’s very very productive.