-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Proposal: Optionally respond to application/vnd.pgrst.object+json with application/json #2809
Comments
Hm, I think the Prefer approach is too ad hoc. #1582 looks it might solve your issue in a generic way.
Q: Why is the client using If you're only using it to validate that the response contains 1 row and you can convert the json to an object client-side, then #2164 might be a much easier solution to implement. Edit: Sorry, missed the following
Yeah, then #1582 is the way to go. Just came to my attention that |
Thanks. Feel free to close and if #1582 doesn't support this I can reopen.
To clarify: the frontend expects single objects for every endpoint, so I changed I was thinking: if you're sending |
Actually, would you welcome a docs PR that points out that |
That seems sensible. Unfortunately at this stage it would a breaking change since there are many client libraries out there.
Sure. Please go ahead. |
No. Even though our response might be valid |
I agree that's the right approach; my impression was that |
Environment
Description of
issuefeature requestI think I would like to configure postgrest to reply to
Accept: application/vnd.pgrst.object+json
requests withContent-Type: application/json
. Ifapplication/vnd.pgrst.array+json
is added, following #2676, I would like the option to vary theContent-Type
for that, too.If this is of interest, I'd be happy to work on it. I'd imagine something like a
Prefers: content-type=application/json
header might work, as might a configuration option (to apply this to all such responses), but I'm not familiar with the postgrest code.I did search the issue tracker, and the closest things I found were #2188, and (via that) #1582.
I'm working with a frontend client that checks a response is json by checking the start of the
Content-Type
isapplication/json
. This seems like a bug on this client's part — it ought to check that the start isapplication/
and there's a+json
before either the end or a;
. Alas, that isn't the case, and I've had a horrible time debugging (it was compounded by another bug where if it doesn't match the header, it returns theResponse
object rather than the result of calling the.text()
method… don't ask). The right solution for my issue is to fix the frontend code (for various reasons I can't do that now, but it's fine, I'm altering the headers in the reverse proxy).Anyway, thanks, team, for all your work on this.
The text was updated successfully, but these errors were encountered: