Releases: alphasights/ember-graphql-adapter
Allow explicit relationship resolution
Problem
When resolving an ember model object graph, objects that contain relationships that itself contain relationships with the same name do not get resolved.
Example:
+-- industry
+-- id
+-- title
+-- details
+-- geographies
| +-- id
| +-- name
| +-- code
+-- companies
| +-- id
| +-- name
+-- subIndustries
+-- id
+-- title
+-- details
+-- geographies (missing)
| +-- id
| +-- name
| +-- code
+-- companies (missing)
+-- id
+-- name
Given the industry object graph above, an industry's relationships (geographies, companies) are missing from the response of an industry's graphql query.
Root problem
The ember-graphql-adapter
keeps track of visited
relationships by the relationship name. If it encounters the same relationship name again, it will not walk down that path when parsing and building the ember object graph. This results in a generated graphql query with child relationships missing relationships.
Solution
Extend the options of the ember model definition with resolveAlways
. When the parser encounters this option, it will traverse this relationship even if it has already been visited
.
Correctly escape string queries
v1.1.3 Bump version to 1.1.3
Correctly stringify arguments that are objects
E.g. Given a model:
import DS from 'ember-data';
export default DS.Model.extend({
comment: DS.belongsTo('comment', { async: false })
});
When calling .save()
on an instance of this model, the query would be serialized like this by ember-graphql-adapter
:
mutation post_update (id: "1", comment: "object Object") { id comments { id body } }
To allow the usage of async: false
and to allow your GraphQL schema to accept objects as arguments, the adapter will now serialize the above example like so:
mutation post_update(id: "1", comment: { id: "2", body: "bar" }) { id comments { id body } }
v1.1.0
v1.0.3
- Reject promise when the adapter ajax request's promise rejects.
Something dodgy happened publishing 1.0.2 😅
v1.0.1
- Adapter now rejects the ajax request's promise when an
errors
key is present on the response. This behaviour was inadvertently removed in v0.4.0
v1.0.0
- Correctly stringify arguments that are arrays of objects
E.g. Given a model:
import DS from 'ember-data';
export default DS.Model.extend({
comments: DS.hasMany('comments', { async: false })
});
When calling .save()
on an instance of this model, the query would be serialized like this by ember-graphql-adapter:
mutation post_update (id: "1", comments: "[object Object]") { id comments { id body } }
To allow the usage of async: false
and to allow your GraphQL schema to accept arrays of objects as arguments, the adapter will now serialize the above example like so:
mutation post_update(id: "1", comments: [{ id: "1", body: "foo"}, { id: "2", body: "bar" }]) { id comments { id body } }