leveluptuts / gQuery

Not like jQuery. A GraphQL Fetcher & Cache for Svelte Kit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Batch Queries

rallisf1 opened this issue · comments

So, I have a usecase where I load multiple components on my site and I had a query for each of them, but soon I realised that even though sveltekit caches the responses, the http requests were still being made and the client had to wait for like 7-8 requests upon each page navigation.

I then merged most of the queries and now only 2 requests happen on each route (1 for the components and 1 for the page content) and things are a lot better. What I noticed though on my backend is that it supports batch queries and also provides a link on apollo's documentation on how it is implemented: https://www.wpgraphql.com/docs/wpgraphql-vs-wp-rest-api/#batch-queries

As I said, 2 requests per route are fine by me and I know this is a small project and chances of implementing any new features are slim, but here it is :D

P.S. Thanks for this lib, it's actually the most painless graphql client anyone can use with sveltekit atm.
P.S.2. Just editing gFetch to support multiple queries won't cut it I'm afraid as I am fetching the components query in my main __layout, since they are common to most routes.

Yeah so this does support batched as you mentioned in the PS2, but I'm not sure the best way to implement that into the codegen side of things.