mirror of
https://github.com/BradNut/gQuery
synced 2025-09-08 17:40:18 +00:00
updates readme
This commit is contained in:
parent
eb63167291
commit
0be3bfb2b3
1 changed files with 19 additions and 3 deletions
22
README.md
22
README.md
|
|
@ -59,7 +59,7 @@ This also gives us a `get` function for queries based on the query name. ie `get
|
|||
```
|
||||
<script context="module" lang="ts">
|
||||
// The generated function that fetches and caches
|
||||
import { getUser } from '../whatever'
|
||||
import { getUser } from './UserQueries.gGenerated.graphql'
|
||||
|
||||
export async function load({fetch}) {
|
||||
// Runs the cache/fetch function populating $gCache before use.
|
||||
|
|
@ -86,10 +86,26 @@ This also gives us a `get` function for queries based on the query name. ie `get
|
|||
|
||||
It's a Svelte Writable Store. So after a mutation you can quickly and easily manually update the cache.
|
||||
|
||||
```
|
||||
import { user, someMutation } from './UserQueries.gGenerated.graphql'
|
||||
|
||||
$user = null // clears the cache
|
||||
|
||||
$user = await someMutation({ variables }) // if this returns the correct data
|
||||
|
||||
```
|
||||
|
||||
### Q? Can't you update the cache magically for me after a mutation?
|
||||
|
||||
Maybe? If you want to be in charge of writing that bit, the door is open 😼
|
||||
Maybe? If you want to be in charge of writing that bit, the door is open 😼. My idea for the api would look something like this.
|
||||
|
||||
```
|
||||
import { user, someMutation } from './UserQueries.gGenerated.graphql'
|
||||
|
||||
await someMutation({ variables, store: user })
|
||||
|
||||
```
|
||||
|
||||
### Q? Why can't I use this yet?
|
||||
|
||||
It's changing too much rn, but will be available asap. Trust me, the sooner I get this done the better.
|
||||
IT'S GETTING CLOSER
|
||||
|
|
|
|||
Loading…
Reference in a new issue