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

Infer query inputs / variables from URLSearchParams #1210

Open
pixelmund opened this issue Oct 6, 2023 · 2 comments
Open

Infer query inputs / variables from URLSearchParams #1210

pixelmund opened this issue Oct 6, 2023 · 2 comments
Labels
Enhancement A new feature or improvement to Houdini's public API Router Issues related to the React framework SvelteKit Issues related to the SvelteKit integration

Comments

@pixelmund
Copy link
Contributor

Describe the feature

in #789 @jycouet suggested to expand the route parameter inferring to also use url.searchParams, i think the comment got lost or wasn't considered at that moment. Imo this would improve filtering / searching in many applications and is probably worth exploring more, since we know all parameters a query needs ahead of time we should be able to easily do this.

I love Houdini and just coming back to using it on my side projects. The only thing i don't really enjoy is the way variables for queries work in general. +page.gql files are awesome and really intuitive! But once you need some kind of variable that isn't included as route parameter you have to create a +page.ts to export this weird _Variables function or move to _houdini_load to have both in the same file.

Criticality

cool improvement, my projects will benefit from it

@pixelmund pixelmund changed the title Infer query parameters from URLSearchParams Infer query inputs / variables from URLSearchParams Oct 6, 2023
@jycouet
Copy link
Collaborator

jycouet commented Oct 6, 2023

👋 hey hi, nice to see you around.
Yes, back then we decided to postpone this topic, happy to bring it back here.

Today, when you forgot a variable, you get an immediate warning at build time that you are missing something. When starting to look at SearchParams, we can't really check at build time. At runtime, if you don't have good SearchParams, you will experience failing queries.

One way could be to opt-in this behavior? with a directive @dont_check_variables_function_and_use_search_params (with a better name 😅)

@pixelmund
Copy link
Contributor Author

That makes sense, thanks for clarifying! 🙂

Maybe we could allow only non required variables to be defined by search params, that way it shouldn't cause any failing queries, since most of the time you will have some kind of default or logic in place to handle them accordingly. (e.g. search filter, order by, etc.)

A directive/opt-in sounds also good to me.

@AlecAivazis AlecAivazis added Enhancement A new feature or improvement to Houdini's public API SvelteKit Issues related to the SvelteKit integration Router Issues related to the React framework labels Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement A new feature or improvement to Houdini's public API Router Issues related to the React framework SvelteKit Issues related to the SvelteKit integration
Projects
None yet
Development

No branches or pull requests

3 participants