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

Allow pass query string into route helper. #1012

Merged
merged 3 commits into from Feb 22, 2019
Merged

Conversation

b0jia
Copy link
Contributor

@b0jia b0jia commented Dec 18, 2018

Proposed changes

Pass query object into route helper second argument to make query string.

Follow issue: #716

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Further comments

Sample Code

route('posts.show', { id: 1, query: { foo: 'bar' } })
// => /post/1?foo=bar
<a href="{{ route('posts.show', { id: 1, query: { foo: 'bar' } }) }}">Show post</a>
<!-- href="/post/1?foo=bar" -->

@coveralls
Copy link

coveralls commented Dec 18, 2018

Coverage Status

Coverage increased (+0.05%) to 95.382% when pulling 6633e38 on BoJiaSu:develop into 9b9c2ba on adonisjs:develop.

@thetutlage
Copy link
Member

Can you please also open another PR for the docs?

@b0jia
Copy link
Contributor Author

b0jia commented Dec 27, 2018

Sure, here is the document. PR#330

@RomainLanz
Copy link
Member

Hey @BoJiaSu! 👋

Sorry for the late reply.
After some internal discussion, we think it's better to not merge this PR.

It would be better to have a new option in the third argument or add a new argument (fourth) for the query string.

The reason behind this is that query or qs could be a route parameter and therefore this would break an actual code.

@RomainLanz RomainLanz self-assigned this Jan 18, 2019
@b0jia
Copy link
Contributor Author

b0jia commented Jan 22, 2019

Hi @RomainLanz, 😀

I moved the query params to third argument.

Now, the new calling method is:

route('posts.show', { id: 1 }, {
  query: { foo: 'bar' }
});
// - or -
route('posts.show', { id: 1 }, {
  qs: { foo: 'bar' }
});
// => /post/1?foo=bar

I will update document's PR later.

@RomainLanz
Copy link
Member

Cool! What do you think @thetutlage?

@pedro-santiago
Copy link

Quite nice! Was looking for a way to add Method Spoofing to this helper, this could be a way. Nice job @BoJiaSu !

@b0jia
Copy link
Contributor Author

b0jia commented Jan 25, 2019

I updated document PR#330.

@jsdecena
Copy link

This is a much needed feature on the app :) 💯 🎉

@RomainLanz RomainLanz merged commit a8a75ce into adonisjs:develop Feb 22, 2019
@jsdecena
Copy link

🎉😍

@lock
Copy link

lock bot commented Mar 10, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants