Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructs incorrect query when gathering a collection that contains a single object. #28

Open
abepetrillo opened this issue Apr 13, 2016 · 2 comments

Comments

@abepetrillo
Copy link

Given an ember model:

export default DS.Model.extend({
resources: DS.hasMany('resources', async: true)
});

In the case where resources is [1], the adapter assumes that the graphql api has the singular type available, and you can end up getting an error similar to:

    {"0"=>"Field 'resource' doesn't exist on type 'Query'"}

This means that to make this workable, you need to make sure the API has both the singular and plural way of accessing the resource which can be quite verbose.

@Arkham
Copy link
Contributor

Arkham commented May 4, 2016

The implementation follows closely the defaults of the other ember data serializers, so for example in the case of REST and AMS serializers it will attempt to access the 'show' endpoint when the associated resource is singular and it will access the 'index' endpoint only when there are multiple associated resources.

@daemonsy
Copy link

daemonsy commented Aug 8, 2016

This might be solveable by implementing the node interface of GraphQL where any object can be globally fetched. Will be looking into this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants