This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a53cff
commit 933b5d1
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## GraphQL Codegen Bruno Plugin | ||
This plugin generates a directory with | ||
[Bruno](https://github.com/usebruno/bruno) files with all GraphQL queries in | ||
your codebase | ||
|
||
# Installation | ||
```sh | ||
pnpm add -d @labdigital/graphql-codegen-bruno | ||
``` | ||
|
||
# Usage | ||
Create a `codegen.ts` file in the root of your project with the following content: | ||
|
||
```ts | ||
import type { CodegenConfig } from "@graphql-codegen/cli"; | ||
|
||
const config: CodegenConfig = { | ||
schema: | ||
"schema.graphql", | ||
documents: [ | ||
"src/**/*.{ts,tsx}" | ||
], | ||
generates: { | ||
// Generate Bruno files in the api-collection directory | ||
"api-collection/generated.json": { | ||
plugins: ["@labdigital/graphql-codegen-bruno"], | ||
config: { | ||
|
||
// Clean the output directory before generating the files | ||
clean: true | ||
|
||
// Set default values for the generated Bruno variables | ||
defaults: { | ||
locale: "nl-NL", | ||
currency: "EUR" | ||
} | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; | ||
``` | ||
Then run the following command: | ||
```sh | ||
pnpx graphql-codegen --config codegen.ts | ||
``` | ||
# Notes | ||
The `api-collection/generated.json` seems to be needed for GraphQL codegen | ||
to work (we need to generate a file, not a directory). If you know a way to | ||
generate a directory instead of a file, please us know | ||