-
Notifications
You must be signed in to change notification settings - Fork 122
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
Path builder and query parameters #160
Comments
+1 for being able to configure the default |
@pgilad / @zachdixon I'd be happy to merge an API like this one if somebody wants to submit a pull-request! -- Sorry I didn't comment sooner. It was a busy end-of-year! |
@fbartho @zachdixon @pgilad May I create the pull-request if nobody planning? |
Hey all, I'm not sure if any work has been done with this yet? I'd certainly +1 the ability to use our own serialiser for the search params. I had a problem today where an array was incorrectly serialised by In the end I intercepted the variables from teh |
Checking back in -- if people want to submit a PR it's up for grabs, if no progress happens next time I do an Issue sweep, then I'll close this ticket! |
Several key points come to mind after having worked with
apollo-link-rest
for a legacy backend (read: not graphql), also seeing that you guys requested comments on the design of it. I'm not a fan of having both path (backend-uri) and query (search) parameters in the same string. It makes handling more complicated cases too complex. I'm also not a fan of forcing the user to useqs
module without his ability to configure it, or use an alternative module (or none at all).For the following points, I make observations on terms:
path
: the backend-uri, not including search/filter parametersquery
: the search parameters (the ones that come after?
)The handling of
path
andquery
should be:path
remains a@rest
directive variable. We drop all legacy variations (i.e:id
) and support only{}
expansions, we also support nested objects expansions off course. The expanded variable is always converted to string (so object will turn in to [object object])path
(withoutquery
) isencodeURI
by default, configurable fromRestLink
options as a global behavior, with possible override by@rest
directive. If the user turns this off then it's the user responsibility to encode his path and variables correctly.@rest
directive, which is namedquery
(or perhapssearch
). This variable behaves similarly topath
with variable expansion - i.e using{}
. If the expanded variable is a string it isencodeURIComponent
. If the variable is an object it gets stringified using either the defaultqueryStringifiers
function, or as a dictionary lookup for a specificqueryStringifiers
function.Re:
queryStringifiers
- it is a dictionary defined atRestLink
options. Defining a default function is required if the user has an expandedquery
variable that is an object (otherwise an error is thrown). Using this strategy allows the user to opt-in to query stringifier, to opt-in for how to stringify the query object and which library to use. Off course we recommend a default function that the user can copy-paste (and installqs
on his own, the way he does today because it's apeer-dependency
).Suggested usage:
We'll need to modify how
pathBuilder
works, but overall it would be very simple (regex replace).Off course this change breaks backwards compat, and we'll need to bump
major
version for this.Thoughts? Comments?
The text was updated successfully, but these errors were encountered: