Skip to content

Releases: alphasights/ember-graphql-adapter

Allow explicit relationship resolution

12 Aug 14:53
c2b02bd
Compare
Choose a tag to compare

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

17 Sep 19:22
Compare
Choose a tag to compare
v1.1.3

Bump version to 1.1.3

Correctly stringify arguments that are objects

02 Feb 19:24
Compare
Choose a tag to compare

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

30 Nov 20:01
Compare
Choose a tag to compare

Release v1.1.0 (November 30, 2017)

  • #174 Update ember to the new 2.16 release
  • #175 Fix incoherent usage of ember-inflector
  • #177 Migrate to new ember modules api
  • #176 Update ember-cli to version 2.17.0

v1.0.3

13 Sep 11:29
Compare
Choose a tag to compare
  • Reject promise when the adapter ajax request's promise rejects.

Something dodgy happened publishing 1.0.2 😅

v1.0.1

12 Sep 15:16
Compare
Choose a tag to compare
  • 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

12 Sep 15:04
Compare
Choose a tag to compare
  • 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 } }