E.g. when requesting my user data from /jsonapi/user/user I can get only my UUID by filtering ?fields[user--user]=uuid .
However if I have thousands of users the output payload gets huge because for all other accounts I get 403 as meta.errors and therefore JSON API response is something like:
{
"data": [
{
"type": "user--user",
"id": "2596ec3c-3d58-4af4-b3cc-d6ae9ec5c3b0",
"attributes": {
"uuid": "2596ec3c-3d58-4af4-b3cc-d6ae9ec5c3b0"
},
"links": {
"self": "http://stage.habinator.com/jsonapi/user/user/2596ec3c-3d58-4af4-b3cc-d6ae9ec5c3b0"
}
}
],
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": "http://jsonapi.org/format/1.0/"
}
}
},
"meta": {
"errors": [
{
"title": "Forbidden",
"status": 403,
"detail": "The current user is not allowed to GET the selected resource.",
"links": {
"info": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4"
},
"code": 0,
"id": "/user--user/62590b54-8c49-427d-8ad0-cf2f8a9d4fdb",
"source": {
"pointer": "/data"
}
},
{
"title": "Forbidden",
"status": 403,
... thousand times.
So how can I omit the meta part altogether?
Comments
Comment #2
gabesulliceHi @TipiT! Thanks for opening an issue for this.
Two things:
?fields[user--user]=uuidis not a filter, it is a "sparse field set". It's saying, "only print the uuid field". What you want is?filter[uuid]={uuid}. IOW, usefilternotfieldsas the query param name.Let me know if you have any other questions! Also, when you're finished with your project, please consider filing an experience report like this one. Those reports give us maintainers extra motivation to keep working on open source :)
Comment #3
wim leersI think #2 could've said three things, so I'll append one 🙂
meta.errorsentries are a thing of the past since JSON API responses now contain a `meta.omitted` object when resources have been removed from the response for access reasons!Comment #4
wim leersComment #5
tipit commentedReally nice guys!
For fast support and implementing this. I'll try it ASAP.