question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamically set query params

See original GitHub issue

I would like to be able to define some query parameters dynamically. My first approach is to do this from the Route in setupController:

  setupController(controller, model) {
    // Parachute things here, dynamically build QP configuration object

    const parachuteController = controller.reopen(ParachuteParams.Mixin);
    super.setupController(parachuteController, model);
  }

This does not work because the query params don’t seem to be set or updated when the properties are changed on the controller.

I’ve researched this quite a bit, but I can’t find any different approach other than this discussion.

Any thoughts appreciated, thanks

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
velrestcommented, Nov 14, 2018

I actually found somewhat of a solution for my problem:

const QueryParams = new QueryParams(
  {
    inFilter: {
      defaultValue: null,
      refresh: true
    },
    notInFilter: {
      defaultValue: null,
      refresh: true
    }
  },
  true
);

export default Component.extend(QueryParams.Mixin, {
  init() {
    // Set `as` dynamically based on component attributes
    set(QueryParams, "queryParams.inFilter.as", this["filter-field"]);
    set(QueryParams, "queryParams.notInFilter.as", `not_in_${this["filter-field"]}`);
    //...
  }
});

I looked into the source code and the query-params are computed based off the original object which the mixin is generated from. So if we reset as on the qp’s on the original object the mixin also has the new attributes.

1reaction
velrestcommented, Nov 13, 2018

on a side note; is it possible to dynamically set the as attribute since i use my component for multiple models and they have different QP names.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamically create query Params in Angular 2 - Stack Overflow
i want to achieve that the queryParams can be dynmamically passed it. For now i can set the values of the params dynamically,...
Read more >
How do you set dynamic query parameters in Mule 4
Here "dynamicQueryParams" is created inside a dataweave and it can be dynamic based on all application conditions in dataweave. Let me know if...
Read more >
How to pass Query parameter dynamically in REST API method
1) Set ${order_number} in query parameter value · 2) Click Auto Generate Variables related link · 3) Make sure Variable is added in...
Read more >
Dynamic M query parameters in Power BI Desktop
With dynamic M query parameters, model authors can ensure that filter selections incorporate into source queries at the right point to achieve ...
Read more >
How to dynamically add a query string to all links in a page
Recently I needed to modify all the links in my blog to add a query string parameter. As you can imagine, this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found