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

Unclear if :relationships can be hydrated #105

Closed
vemv opened this issue Mar 2, 2018 · 3 comments
Closed

Unclear if :relationships can be hydrated #105

vemv opened this issue Mar 2, 2018 · 3 comments

Comments

@vemv
Copy link

vemv commented Mar 2, 2018

Hi!

Dunno if this is more of a concern of http://jsonapi.org/, but:

it is unclear whether the items contained in :relationships can/should have richer keys than just id and type.

"relationships":{"foos":{"data":[{"id":"2","type":"foo"}]},"bars":{"data":[{"id":"8","type":"bar"}]}}

When one sees this generated json, may wonder "can I have more fields there?"

I am aware that there's included, but ideally one would avoid generating bloated representations. Particularly for a performance-sensitive lib :)

Cheers - Victor

@devtoro
Copy link

devtoro commented Mar 3, 2018

This is the json-api "standard". Maybe you could try GraphQL for what you ask or you could send your data under the "included" key like so:

"data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!"
    }
  }
],
"included": [{
    "type": "people",
    "id": "9",
    "attributes": {
      "first-name": "Dan",
      "last-name": "Gebhardt",
      "twitter": "dgeb"
    },
    "links": {
      "self": "http://example.com/people/9"
    }
  }]

@hidde-jan
Copy link

This is (kind of) a duplicate of #101, but with the inclusion of the request for sparse fieldsets. JSON API already has specified how apis should handle these things, with includes (http://jsonapi.org/format/#fetching-includes) and sparse fieldsets (http://jsonapi.org/format/#fetching-sparse-fieldsets).

Some more pointers to the JSON API docs in the readme might squash these questions. It seems that sparse field sets are currently not supported.

@shishirmk
Copy link
Collaborator

The request is not supported by jsonapi standard as @hidde-jan has answered. A combination of includes and sparse fieldsets should provide similar functionality. Includes is supported by not sparse fieldsets.

Closing as sparse field sets are already captured as an enhancement

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

4 participants