-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Update ember-and-json-api.md #1894
Conversation
Removed ember-data adapter change to support include directives, as it's now built-in. Updated the documentation for how to add include directives to ember store queries, and added documentation covering how to tell Rails that we are consuming and generating jsonapi data
@Ikariusrb, thanks for your PR! By analyzing the annotation information on this pull request, we identified @NullVoxPopuli, @kyleshevlin and @bf4 to be potential reviewers |
|
||
```ruby | ||
# config/initializers/active_model_serializers.rb | ||
require 'active_model_serializers/register_jsonapi_renderer' | ||
``` | ||
Rails also requires your controller to tell it that you accept and generate JSONAPI data. To do that, you use `respond_to` in your controller handlers. You can add `ActionController::MimeResponds` to your application controller to enable this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this? was this mentioned in the slack convo you had with @bf4? might be a good idea to state why you need respond_to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more like the following story:
render jsonapi: foo
Client: Hello. I am sending you JSONAPI data. Tell me what you think. I only understand answers in terms of JSON API data
Server: Here's some JSON API data
respond_to do |format| format.jsonapi { render jsonapi: foo } end
Client: Hello. I am sending you JSONAPI data. Tell me what you think. I only understand answers in terms of JSON API data
Server: You want JSON API data? Lemme see if I can do that. I can. Here's some JSON API data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this story.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which means
Rails also requires your controller to tell it that you accept and generate JSONAPI data
Isn't quite true. Rails even has an ignore_accept_header
You may want to rebase this off of master. |
@@ -102,18 +118,16 @@ export default DS.JSONAPISerializer.extend({ | |||
|
|||
``` | |||
|
|||
|
|||
## Including Nested Resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to mention the whole 'embedded resources' controversy here and how it's not JSON API so we don't do it, but ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, maybe mention the difference between including, and embedding, and that there are ways to embed, such as: https://github.com/NullVoxPopuli/aeonvera/blob/master/config/initializers/active_model_serializers.rb#L18
@Ikariusrb do you think you can finish this up? |
Updates to address comments; explain why Rails should know what format we are consuming/generating, reword introduction to include: examples, and fix render statement to specify jsonapi instead of json.
* Update ember-and-json-api.md Removed ember-data adapter change to support include directives, as it's now built-in. Updated the documentation for how to add include directives to ember store queries, and added documentation covering how to tell Rails that we are consuming and generating jsonapi data * Fix up format for parameter restrictions * Update ember-and-json-api.md Updates to address comments; explain why Rails should know what format we are consuming/generating, reword introduction to include: examples, and fix render statement to specify jsonapi instead of json.
Purpose
Update the ember integration documentation
Changes
Update documentation for how to get ember to use include directives
Add documentation on how to update controllers to tell Rails we are consuming and generating jsonapi data.
Caveats
Related GitHub issues
Additional helpful information
Removed ember-data adapter change to support include directives, as it's now built-in. Updated the documentation for how to add include directives to ember store queries, and added documentation covering how to tell Rails that we are consuming and generating jsonapi data