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

README Show graphql syntax used #147

Open
jrock2004 opened this issue Aug 14, 2017 · 4 comments
Open

README Show graphql syntax used #147

jrock2004 opened this issue Aug 14, 2017 · 4 comments
Assignees

Comments

@jrock2004
Copy link

In your readme, it would be helpful to see the graphql sybtax that the adapters are trying to use. This will help out understand how to use for our needs.

Something like this

query
{
  Media(search: "Dragonball") {
    title {
      userPreferred
    },
    description
  }
} 
@willrax
Copy link
Contributor

willrax commented Aug 14, 2017

Hey @jrock2004 Sounds good. Do you mean incoming or outgoing? Or both?

@willrax willrax self-assigned this Aug 14, 2017
@jrock2004
Copy link
Author

I am just confused how I would create my models and adapters to match the graphql syntax like above

@jrock2004
Copy link
Author

Also, is this only supported for ruby? All your docs are in ruby code

@willrax
Copy link
Contributor

willrax commented Aug 15, 2017

I am just confused how I would create my models and adapters to match the graphql syntax like above.

You can set up your ember models as normal and just make sure that both your adapter and serializer are exporting the grapqhl versions. From there the addon will auto generate the correct graph query to send to the backend and parse the response to feed it in the ember-data.

Also, is this only supported for ruby? All your docs are in ruby code.

It should support any graphql backend.

Here's an example from our code base.

models/comment.js

import DS from 'ember-data';

const { attr, belongsTo } = DS;

export default DS.Model.extend({
  body: attr('string'),
  createdAt: attr('date'),
  important: attr('boolean', { defaultValue: false }),

  advisor: belongsTo('advisor', { async: true }),
  user: belongsTo('user', { async: true }),
});

adapters/application.js

import { Adapter } from 'ember-graphql-adapter';

export default Adapter.extend();

serializers/application.js

import { Serializer } from 'ember-graphql-adapter';

export default Serializer.extend();

and this is the query that goes out:

query
  comments { 
    comments(ids: ["1","2","3"]) {
      id
      body
      created_at
      important 
      advisor_id
      user_id
    }
  }

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

2 participants