adds basic api preview

This commit is contained in:
Scott Tolinski 2021-09-29 11:11:21 -06:00
parent 0f7002d0b5
commit 56059c8cce

View file

@ -1,3 +1,61 @@
# qQuery # qQuery
## ## Not like jQuery. A GraphQL Fetcher & Cache for Svelte Kit
### UnderConstruction.gif
More information in this space soon. API is very much in flux rn.
### Preview
## gFetch
The graphql fetcher client.
Initialize
```
export const g = new GFetch({
path: Environment.apiURL
})
```
Fetch
```
const seriesList = ({ variables}) =>
g.fetch<SeriesListQuery>({
queries: [{ query: SeriesListDoc, variables }],
})
```
Cache and Fetch
```
export async function getSeriesList(variables) {
await gQuery('seriesList', { query: seriesList, variables })
}
```
Use
```
<script context="module" lang="ts">
import { getSeriesList } from '../whatever'
export async function load() {
await getSeriesList({
limit: 0
})
return {}
}
</script>
<script lang="ts">
import { gCache } from '@leveluptuts/gQuery'
// $: console.log($gCache.seriesList)
</script>
```