{"action":"created","issue":{"url":"https://api.github.com/repos/ethanresnick/json-api/issues/97","labels_url":"https://api.github.com/repos/ethanresnick/json-api/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/ethanresnick/json-api/issues/97/comments","events_url":"https://api.github.com/repos/ethanresnick/json-api/issues/97/events","html_url":"https://github.com/ethanresnick/json-api/pull/97","id":113115877,"number":97,"title":"Related with no data","user":{"login":"shannonmpoole","id":1154610,"avatar_url":"https://avatars.githubusercontent.com/u/1154610?v=3","gravatar_id":"","url":"https://api.github.com/users/shannonmpoole","html_url":"https://github.com/shannonmpoole","followers_url":"https://api.github.com/users/shannonmpoole/followers","following_url":"https://api.github.com/users/shannonmpoole/following{/other_user}","gists_url":"https://api.github.com/users/shannonmpoole/gists{/gist_id}","starred_url":"https://api.github.com/users/shannonmpoole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shannonmpoole/subscriptions","organizations_url":"https://api.github.com/users/shannonmpoole/orgs","repos_url":"https://api.github.com/users/shannonmpoole/repos","events_url":"https://api.github.com/users/shannonmpoole/events{/privacy}","received_events_url":"https://api.github.com/users/shannonmpoole/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-23T23:22:41Z","updated_at":"2015-10-26T15:16:53Z","closed_at":"2015-10-26T15:16:53Z","pull_request":{"url":"https://api.github.com/repos/ethanresnick/json-api/pulls/97","html_url":"https://github.com/ethanresnick/json-api/pull/97","diff_url":"https://github.com/ethanresnick/json-api/pull/97.diff","patch_url":"https://github.com/ethanresnick/json-api/pull/97.patch"},"body":"As per your suggestion this is to solve #95 \r\n\r\nIt's a very simple change but it didn't quite work the way you had suggested.\r\n\r\nFor example this is how I had to describe the resource:\r\n\r\n```javascript\r\n{\r\n  type: 'groups',\r\n  urlTemplates: {\r\n    self: '/api/v1/groups/{id}',\r\n    related: '/api/v1/{path}?filter[simple][group]={ownerId}'\r\n  },\r\n  beforeRender: function(resource) {\r\n    resource.relationships.projects = new jsonApi.types.RelationshipObject();\r\n    return resource;\r\n  }\r\n}\r\n```\r\n\r\nAnd it results in a document that looks like this:\r\n\r\n```javascript\r\n{\r\n  \"links\": {\r\n    \"self\": \"http://localhost:8001/api/v1/groups\"\r\n  },\r\n  \"data\": [\r\n    {\r\n      \"id\": \"5621a3dbfb9398f40bcd7579\",\r\n      \"type\": \"groups\",\r\n      \"attributes\": {\r\n        \"name\": \"test group\"\r\n      },\r\n      \"links\": {\r\n        \"self\": \"/api/v1/groups/5621a3dbfb9398f40bcd7579\"\r\n      },\r\n      \"relationships\": {\r\n        \"projects\": {\r\n          \"links\": {\r\n            \"related\": \"/api/v1/projects?filter%5Bsimple%5D%5Bgroup%5D=5621a3dbfb9398f40bcd7579\"\r\n          }\r\n        }\r\n      }\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nSo the end result is good but I'm concerned about the fact that I had to add related in urlTemplate for two reasons. \r\n\r\nOne, when I added it to the RelationshipObject as you suggested:\r\n```javascript\r\nresource.relationships.projects = new RelationshipObject(undefined, '/api/v1/{path}?filter[simple][group]={ownerId}');\r\n```\r\nIt ended up giving me a document that looked like this:\r\n```javascript\r\n{\r\n  \"links\": {\r\n    \"self\": \"http://localhost:8001/api/v1/groups\"\r\n  },\r\n  \"data\": [\r\n    {\r\n      \"id\": \"5621a3dbfb9398f40bcd7579\",\r\n      \"type\": \"groups\",\r\n      \"attributes\": {\r\n        \"name\": \"test group\"\r\n      },\r\n      \"links\": {\r\n        \"self\": \"/api/v1/groups/5621a3dbfb9398f40bcd7579\"\r\n      },\r\n      \"relationships\": {\r\n        \"projects\": {}\r\n      }\r\n    }\r\n  ]\r\n}\r\n```\r\nThere is obviously something more going on here that I need go through the source more for. Maybe you can shed some light on this for me.\r\n\r\nThe second reason is that the related key in urlTemplates is not actually documented so I'm not sure I am using it correctly or if I even should be using it."},"comment":{"url":"https://api.github.com/repos/ethanresnick/json-api/issues/comments/151170366","html_url":"https://github.com/ethanresnick/json-api/pull/97#issuecomment-151170366","issue_url":"https://api.github.com/repos/ethanresnick/json-api/issues/97","id":151170366,"user":{"login":"shannonmpoole","id":1154610,"avatar_url":"https://avatars.githubusercontent.com/u/1154610?v=3","gravatar_id":"","url":"https://api.github.com/users/shannonmpoole","html_url":"https://github.com/shannonmpoole","followers_url":"https://api.github.com/users/shannonmpoole/followers","following_url":"https://api.github.com/users/shannonmpoole/following{/other_user}","gists_url":"https://api.github.com/users/shannonmpoole/gists{/gist_id}","starred_url":"https://api.github.com/users/shannonmpoole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shannonmpoole/subscriptions","organizations_url":"https://api.github.com/users/shannonmpoole/orgs","repos_url":"https://api.github.com/users/shannonmpoole/repos","events_url":"https://api.github.com/users/shannonmpoole/events{/privacy}","received_events_url":"https://api.github.com/users/shannonmpoole/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T15:16:53Z","updated_at":"2015-10-26T15:16:53Z","body":"Cool this looks to be included with #99 so no need to keep this one open."}}