mirror of
https://github.com/BradNut/gQuery
synced 2025-09-08 17:40:18 +00:00
changes gGenerated to gq
This commit is contained in:
parent
e2891e3a8d
commit
1c6731897b
4 changed files with 17 additions and 17 deletions
12
README.md
12
README.md
|
|
@ -52,14 +52,14 @@ query user {
|
||||||
|
|
||||||
### 4. Use that thang
|
### 4. Use that thang
|
||||||
|
|
||||||
The code gen will find the file and spit out a file next to it. Named `FileName.gGenerated.ts`
|
The code gen will find the file and spit out a file next to it. Named `FileName.gq.ts`
|
||||||
Using the above code, it would output `UserQueries.gGenerated.ts`
|
Using the above code, it would output `UserQueries.gq.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.
|
||||||
|
|
||||||
```svelte
|
```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.gq.graphql'
|
||||||
|
|
||||||
export async function load({fetch}) {
|
export async function load({fetch}) {
|
||||||
// Runs the cache/fetch function populating $gCache before use.
|
// Runs the cache/fetch function populating $gCache before use.
|
||||||
|
|
@ -73,7 +73,7 @@ This also gives us a `get` function for queries based on the query name. ie `get
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// Cache becomes populated with data available for SSR
|
// Cache becomes populated with data available for SSR
|
||||||
import { user } from './UserQueries.gGenerated.graphql'
|
import { user } from './UserQueries.gq.graphql'
|
||||||
|
|
||||||
// $: console.log($user.user) //data available for ssr
|
// $: console.log($user.user) //data available for ssr
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -87,7 +87,7 @@ 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
|
```javascript
|
||||||
import { user, someMutation } from "./UserQueries.gGenerated.graphql";
|
import { user, someMutation } from "./UserQueries.gq.graphql";
|
||||||
|
|
||||||
$user.user = null; // clears the cache
|
$user.user = null; // clears the cache
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ $user.user = await someMutation({ variables }); // if this returns the correct d
|
||||||
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
|
```javascript
|
||||||
import { user, someMutation } from "./UserQueries.gGenerated.graphql";
|
import { user, someMutation } from "./UserQueries.gq.graphql";
|
||||||
|
|
||||||
await someMutation({ variables, store: user });
|
await someMutation({ variables, store: user });
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,15 @@ export default function levelupViteCodegen(options) {
|
||||||
name: "g-query-codegen",
|
name: "g-query-codegen",
|
||||||
async buildStart() {
|
async buildStart() {
|
||||||
try {
|
try {
|
||||||
// *1. Remove all .gGenerated files
|
// *1. Remove all .gq files
|
||||||
// TODO: Find and remove all .gGenerated files
|
// TODO: Find and remove all .gq files
|
||||||
// *2. Generate
|
// *2. Generate
|
||||||
await generate({
|
await generate({
|
||||||
schema,
|
schema,
|
||||||
documents: "./src/**/*.graphql",
|
documents: "./src/**/*.graphql",
|
||||||
generates: {
|
generates: {
|
||||||
// * Generates the types for your schema
|
// * Generates the types for your schema
|
||||||
[`${process.cwd()}/${output}/types.gGenerated.ts`]: {
|
[`${process.cwd()}/${output}/types.gq.ts`]: {
|
||||||
plugins: ["typescript"],
|
plugins: ["typescript"],
|
||||||
},
|
},
|
||||||
// * Generates near file .ts files for your fetch functions
|
// * Generates near file .ts files for your fetch functions
|
||||||
|
|
@ -37,9 +37,9 @@ export default function levelupViteCodegen(options) {
|
||||||
},
|
},
|
||||||
preset: "near-operation-file",
|
preset: "near-operation-file",
|
||||||
presetConfig: {
|
presetConfig: {
|
||||||
extension: ".gGenerated.ts",
|
extension: ".gq.ts",
|
||||||
folder: "./",
|
folder: "./",
|
||||||
baseTypesPath: `types.gGenerated.ts`,
|
baseTypesPath: `types.gq.ts`,
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
"typescript-operations",
|
"typescript-operations",
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,uCAAuC;AAEzE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,OAAO;IAChD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;IACD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAClB,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;KACH;IAED,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE1C,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC9B,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,KAAK,CAAC,UAAU;YACd,IAAI;gBACF,qCAAqC;gBACrC,8CAA8C;gBAC9C,iBAAiB;gBAEjB,MAAM,QAAQ,CACZ;oBACE,MAAM;oBACN,SAAS,EAAE,oBAAoB;oBAC/B,SAAS,EAAE;wBACT,wCAAwC;wBACxC,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,MAAM,sBAAsB,CAAC,EAAE;4BAClD,OAAO,EAAE,CAAC,YAAY,CAAC;yBACxB;wBACD,2DAA2D;wBAC3D,CAAC,G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
||||||
name: "g-query-codegen",
|
name: "g-query-codegen",
|
||||||
async buildStart() {
|
async buildStart() {
|
||||||
try {
|
try {
|
||||||
// *1. Remove all .gGenerated files
|
// *1. Remove all .gq files
|
||||||
// TODO: Find and remove all .gGenerated files
|
// TODO: Find and remove all .gq files
|
||||||
// *2. Generate
|
// *2. Generate
|
||||||
|
|
||||||
await generate(
|
await generate(
|
||||||
|
|
@ -31,7 +31,7 @@ export default function levelupViteCodegen(options) {
|
||||||
documents: "./src/**/*.graphql",
|
documents: "./src/**/*.graphql",
|
||||||
generates: {
|
generates: {
|
||||||
// * Generates the types for your schema
|
// * Generates the types for your schema
|
||||||
[`${process.cwd()}/${output}/types.gGenerated.ts`]: {
|
[`${process.cwd()}/${output}/types.gq.ts`]: {
|
||||||
plugins: ["typescript"],
|
plugins: ["typescript"],
|
||||||
},
|
},
|
||||||
// * Generates near file .ts files for your fetch functions
|
// * Generates near file .ts files for your fetch functions
|
||||||
|
|
@ -44,9 +44,9 @@ export default function levelupViteCodegen(options) {
|
||||||
},
|
},
|
||||||
preset: "near-operation-file",
|
preset: "near-operation-file",
|
||||||
presetConfig: {
|
presetConfig: {
|
||||||
extension: ".gGenerated.ts",
|
extension: ".gq.ts",
|
||||||
folder: "./",
|
folder: "./",
|
||||||
baseTypesPath: `types.gGenerated.ts`,
|
baseTypesPath: `types.gq.ts`,
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
"typescript-operations", // operations, gets you types for operations (queries and mutations)
|
"typescript-operations", // operations, gets you types for operations (queries and mutations)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue