Why are we using resource type when defining sparse fields?


When defining sparse fields we use resource type as the key.
Instead can’t we use relation / alias as the key?
My consideration is if a relation’s type is same as primary data’s type it will potentially include unwanted data.
ex:- primary data type: people. relation: friends. this is also of people type. included friends collection will also have attributes requested for primary data.


The spec doesn’t currently allow this. But your analysis is correct, and we might extend the fields parameter in the future to support this. I’ve linked to this thread in our issue on possible extensions, to keep this problem on the radar.


Sparse fieldsets per relationship is probably a duplicated of this one that contains a little bit of extra context.