api-platform icon indicating copy to clipboard operation
api-platform copied to clipboard

what is the best way to add current user information related to GetCollection request

Open SakhriHoussem opened this issue 10 months ago • 5 comments

what is the best way to add current user information related to GetCollection request without losing pagination and filters

example request for a list of articles and I want to add the current user information if this article is saved or not

SakhriHoussem avatar Apr 08 '24 11:04 SakhriHoussem

I would add a new field to the response. I haven't been using apiplatform for a while but I believe this can be achieved via custom normalizer that get a user from the token and adds new field with expected data.

P.S. This is not an issue but a discussion.

javaDeveloperKid avatar Apr 08 '24 12:04 javaDeveloperKid

@javaDeveloperKid have you thought about how many items I would have to go through to fill this new field?

SakhriHoussem avatar Apr 08 '24 12:04 SakhriHoussem

What do you mean by "how many items I would have to go through"? The collection for the resource is added by another normalizer.

javaDeveloperKid avatar Apr 08 '24 12:04 javaDeveloperKid

That seems like a simple custom state provider to me...?

mrossard avatar Apr 08 '24 13:04 mrossard

@mrossard what if your provider gives you a Paginator? how do you change this custom field

SakhriHoussem avatar Apr 08 '24 16:04 SakhriHoussem