buro26-graphql-codegen-sdk
v0.0.10
Published
Generate a graphql client sdk for any graphql api
Downloads
279
Maintainers
Readme
GraphQL Codegen SDK
Generate a SDK for your GraphQL API using GraphQL Codegen.
Getting started
npm i buro26-graphql-codegen-sdk
Usage
Create a codegen.ts file in the root of your project with the following content:
Add a script to your package.json to run the codegen:
{
"scripts": {
"codegen": "graphql-codegen"
}
}
Run the codegen script:
npm run codegen
Configuration
Create a codegen.ts file in the root of your project with the following content:
import {createConfig} from 'buro26-graphql-codegen-sdk'
export default createConfig({
schema: 'http://localhost:1337/graphql',
documents: 'src/lib/my-api/queries/**/!(*.generated).{ts,tsx}',
typesImportPath: '@/lib/my-api/generated/types',
schemaImportPath: '@/lib/my-api/generated/schema',
types: {
path: 'src/lib/my-api/generated/types.ts'
},
sdl: {
path: './schema.graphql'
},
client: {
path: 'src/lib/my-api/generated/client-factory.ts',
config: {
logger: true
}
},
zod: {
path: 'src/lib/my-api/generated/schema.ts',
config: {
exportFormDataSchema: true,
},
}
})
Usage
Add a script to your package.json to run the codegen:
{
"scripts": {
"codegen": "graphql-codegen"
}
}
Run the codegen script:
npm run codegen
Client
On more how to use the generated client, see the buro26-graphql-codegen-client package.
Zod Schema
On more how to use the generated zod schema, see the buro26-graphql-codegen-zod package.
Test and Deploy
Running tests
To run tests, run the following command:
bun test
Contributing
Wish to contribute to this project? Pull the project from the repository and create a merge request.
Authors and acknowledgment
Buro26 - https://buro26.digital
Special thanks to all contributors and the open-source community for their support and contributions.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project status
The project is currently in active development. We are continuously working on adding new features and improving the existing ones. Check the issues section for the latest updates and planned features.
Feel free to reach out if you have any questions or suggestions!