What's the correct way to specify Sparse Fieldsets for Deep Relationship Includes?



The specification is quite clear on the use of the include parameter - it clearly indicates that dot notation should be used to specify relationship paths, e.g. comments.author in the #Spec: Fetching-includes section

What the spec is not clear on how this translates to sparse fieldsets (i.e. no mention of dot notation).

For example, a contrived example

Which is more in-line with the specification, option 1 or option 2

  1. GET
  2. GET

Where a:

  • A Person has a Group.
  • Group has a Division
  • Division has a list of Managers

~the fool


Keep in mind that a single resource may be included via multiple relationship with multiple other resources, so there’s no practical way to specify a single set of fields via relationship.

Fields are instead specified by type, so you should have params like fields[group], fields[division], fields[manager], etc.


Hi dgeb

Thanks for your response. Feels clean. I was just curious if the spec was going to become stricter in this regard and thought I’d cover that base now. First time I’m implementing the JSON API spec.