From 6a4c950b99c482ab414d8a072cf6beb8da0a3c74 Mon Sep 17 00:00:00 2001 From: jaredcnance Date: Tue, 12 Sep 2017 06:50:15 -0500 Subject: [PATCH] docs(inclusion): cherrypcik documentation from JR Closes #147 --- couscous.yml | 3 ++ docs/IncludingRelationships.md | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 docs/IncludingRelationships.md diff --git a/couscous.yml b/couscous.yml index 90f2b9b095..a169a246f2 100644 --- a/couscous.yml +++ b/couscous.yml @@ -78,6 +78,9 @@ menu: filtering: text: Filtering relativeUrl: filtering.html + includingRelationships: + text: Including Relationships + relativeUrl: includingRelationships.html pagination: text: Pagination relativeUrl: pagination.html diff --git a/docs/IncludingRelationships.md b/docs/IncludingRelationships.md new file mode 100644 index 0000000000..2039025306 --- /dev/null +++ b/docs/IncludingRelationships.md @@ -0,0 +1,54 @@ +--- +currentMenu: includingRelationships +--- + +# Including Relationships + +JADNC supports [request include params](http://jsonapi-resources.com/v0.9/guide/resources.html#Included-relationships-side-loading-resources) out of the box, for side loading related resources. + +Here’s an example from the spec: + +```http +GET /articles/1?include=comments HTTP/1.1 +Accept: application/vnd.api+json +``` + +Will get you the following payload: + +```json +{ + "data": { + "type": "articles", + "id": "1", + "attributes": { + "title": "JSON API paints my bikeshed!" + }, + "relationships": { + "comments": { + "links": { + "self": "http://example.com/articles/1/relationships/comments", + "related": "http://example.com/articles/1/comments" + }, + "data": [ + { "type": "comments", "id": "5" }, + { "type": "comments", "id": "12" } + ] + } + } + }, + "included": [{ + "type": "comments", + "id": "5", + "attributes": { + "body": "First!" + } + }, { + "type": "comments", + "id": "12", + "attributes": { + "body": "I like XML better" + } + }] +} +``` +