mirror of
https://github.com/BradNut/gQuery
synced 2025-09-08 17:40:18 +00:00
adds more langs
This commit is contained in:
parent
c1e4d3fd1d
commit
fe8e6ba618
1 changed files with 10 additions and 12 deletions
22
README.md
22
README.md
|
|
@ -20,7 +20,7 @@ export const g = new GFetch({
|
||||||
|
|
||||||
### 2. Add GraphQL Codegen Plugin
|
### 2. Add GraphQL Codegen Plugin
|
||||||
|
|
||||||
```
|
```javascript
|
||||||
svelte.config.js
|
svelte.config.js
|
||||||
|
|
||||||
import gQueryCodegen from '@leveluptuts/g-query/codegen'
|
import gQueryCodegen from '@leveluptuts/g-query/codegen'
|
||||||
|
|
@ -38,7 +38,7 @@ import gQueryCodegen from '@leveluptuts/g-query/codegen'
|
||||||
|
|
||||||
### 3. Add .graphql files
|
### 3. Add .graphql files
|
||||||
|
|
||||||
```
|
```graphql
|
||||||
UserQueries.graphql
|
UserQueries.graphql
|
||||||
|
|
||||||
query user {
|
query user {
|
||||||
|
|
@ -56,7 +56,7 @@ The code gen will find the file and spit out a file next to it. Named `FileName.
|
||||||
Using the above code, it would output `UserQueries.gGenerated.ts`
|
Using the above code, it would output `UserQueries.gGenerated.ts`
|
||||||
This also gives us a `get` function for queries based on the query name. ie `getUser` for the above.
|
This also gives us a `get` function for queries based on the query name. ie `getUser` for the above.
|
||||||
|
|
||||||
```javascript
|
```svelte
|
||||||
<script context="module" lang="ts">
|
<script context="module" lang="ts">
|
||||||
// The generated function that fetches and caches
|
// The generated function that fetches and caches
|
||||||
import { getUser } from './UserQueries.gGenerated.graphql'
|
import { getUser } from './UserQueries.gGenerated.graphql'
|
||||||
|
|
@ -86,24 +86,22 @@ 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.
|
It's a Svelte Writable Store. So after a mutation you can quickly and easily manually update the cache.
|
||||||
|
|
||||||
```
|
```javascript
|
||||||
import { user, someMutation } from './UserQueries.gGenerated.graphql'
|
import { user, someMutation } from "./UserQueries.gGenerated.graphql";
|
||||||
|
|
||||||
$user = null // clears the cache
|
$user = null; // clears the cache
|
||||||
|
|
||||||
$user = await someMutation({ variables }) // if this returns the correct data
|
|
||||||
|
|
||||||
|
$user = await someMutation({ variables }); // if this returns the correct data
|
||||||
```
|
```
|
||||||
|
|
||||||
### Q? Can't you update the cache magically for me after a mutation?
|
### 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 😼. My idea for the api would look something like this.
|
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.
|
||||||
|
|
||||||
```
|
```javascript
|
||||||
import { user, someMutation } from './UserQueries.gGenerated.graphql'
|
import { user, someMutation } from "./UserQueries.gGenerated.graphql";
|
||||||
|
|
||||||
await someMutation({ variables, store: user })
|
|
||||||
|
|
||||||
|
await someMutation({ variables, store: user });
|
||||||
```
|
```
|
||||||
|
|
||||||
### Q? Why can't I use this yet?
|
### Q? Why can't I use this yet?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue