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

[JsonApiSerializer] A way to return requested realtionship without attributes and links #519

Open
Insolita opened this issue Oct 5, 2020 · 2 comments
Labels

Comments

@Insolita
Copy link

Insolita commented Oct 5, 2020

Even if we transform data as

   transform($data){
       return ['id' => $data['id']];
  }

the response will contain empty attributes object and link object with self-link
like

 "data" : {
            "type":       "users" ,
            "id":         "55" ,
            "attributes": { } ,
            "links":      {
                "self": "http://127.0.0.1:80/users/55"
            }
        }

There is no way to receive a simple response for request like /articles/1/relationships/author
r like in examples https://jsonapi.org/format/#fetching-relationships

 "data" : {"type":  "users" , "id":   "55" }
@Insolita Insolita changed the title [JsonApiSerializer] A way to return requested realtionships without attributes and links [JsonApiSerializer] A way to return requested realtionship without attributes and links Oct 5, 2020
@willishq
Copy link
Member

How are you creating the serializer? If you create the serializer without a base URL, it shouldn't add the links.

Regarding the attributes, that's a tricky one which comes from the current implementation not being able to difrentiate between an empty object and an empty array, there are issues raised about this problem already and the changes required would essentially mean rebuilding the serializer from scratch. In theory, an empty object should not be there, but an empty array should be, so the API consumer knows that there is potentially an amount of items to be iterated over.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 4 weeks if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants