And requesting with sparse fields: http://localhost:4000/posts?fields[posts]=name the resulting response has attributes correctly filtered but has the following additional fields:
# ...
"relationships": {
"comments": {}
}
# ...
And when using identifiers: :always the response also have the following additional fields:
I think for both the above cases the response should respect the sparse fields, and NOT include the comments or even better to just omit the entire relationships object, since the client is only requesting the name fields which is an attribute and in the JSON API spec it states:
If a client requests a restricted set of fields for a given resource type, an endpoint MUST NOT include additional fields in resource objects of that type in its response.
The definition for fields in the JSON API spec include both attributes and relationships:
A resource object’s attributes and its relationships are collectively called its “fields”.
but right now only attributes are being filtered, relationships are not
Currently with the following code:
And requesting with sparse fields:
http://localhost:4000/posts?fields[posts]=name
the resulting response hasattributes
correctly filtered but has the following additional fields:And when using
identifiers: :always
the response also have the following additional fields:I think for both the above cases the response should respect the sparse fields, and NOT include the
comments
or even better to just omit the entirerelationships
object, since the client is only requesting thename
fields which is an attribute and in the JSON API spec it states:The definition for fields in the JSON API spec include both attributes and relationships:
but right now only attributes are being filtered, relationships are not