-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Customize serialization of query parameter lists #7345
Comments
Bump, just ran into this need. While mine isnt nested, I get the following
and spring java wants
|
@cah-brian-gantzler it's unlikely we ever consider this. Those adapters have too many poorly designed hooks and methods as it is. It is much simpler to implement your own adapter. Eventually we will provide url-building util functions, even in that case the answer wouldn't be a hook but to write your own function. |
I believe when I looked into this the functions that performed this was so way down or in utils that could not be overridden. If I could have overridden a method on the base adapter I would have. Im sorry I dont remember where I saw the code needed to be changed, but I dont think writing my own adapter would solve the problem either, I think it was in the build url utilities. Any idea on the time frame of eventually 😄 Thanks for your consideration |
@cah-brian-gantzler eventually is more or less come :) emberjs/rfcs#860 My goal is to land the implementation of this in the next 2 weeks. |
Thanks for the update. My current endpoint is only being called manually until I could figure out what to do. Looking forward to it. Please keep me informed |
Background
If we specify a list as query parameters in the
query
method of theRESTAdapter
(or with the JSONAPIAdapter as it inherits thequery
method), such aswe have a situation, which is not specified in the standard defined on jsonapi.org.
Situation in Ember Data (RESTAdapter and JSONAPIAdapter)
To serialize the query parameters we use a function, which was copied from jQuery and therefore get the same result as with jquery:
Source: https://github.com/emberjs/data/blob/v3.21.0/packages/adapter/addon/-private/utils/serialize-query-params.ts#L11
Since it is all happening in private methods, this behaviour cannot be easily changed for a backend which behaves differently - such as Django Rest Framework Json API.
Situation in Django DJA
Django Rest Framework JSON Api (the Django implementation of jsonapi.org) decided to implement query parameter lists as repeated query parameter like this:
Source: django-json-api/django-rest-framework-json-api#718
Solutions
There should definitely be a way to easily change this behaviour to adapt it to different back ends, especially since it is not defined in the standard.
I'm not sure how this can be resolved. Maybe the function
serializeQueryParams(queryParamsObject)
could be made a public method on the RESTAdapter.The text was updated successfully, but these errors were encountered: