spences10 / sveltekit-with-urql

An example of using URQL with SvelteKit
https://sveltekit-with-urql.vercel.app/
8 stars 2 forks source link

Urql query in load function #73

Open plckr opened 1 year ago

plckr commented 1 year ago

Hey

Isn't it better to put the query inside the load function instead of +page.svelte? https://github.com/spences10/sveltekit-with-urql/blob/main/src/routes/character/%5Bid%5D/%2Bpage.js

spences10 commented 1 year ago

Hey @plckr good point, you want to make a PR for it?

plckr commented 1 year ago

I'm with the same trouble, I don't know how can I achieve that keeping a good readable code. I think the only way is to duplicate the code between the two files which I don't like it much 🤷‍♂️

For example: In a load function you can have the initial fetch, but in the svelte page you can have some filters or variables to change