JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q74519F
  • License MIT

Generate a graphql client sdk for any graphql api

Package Exports

  • buro26-graphql-codegen-sdk
  • buro26-graphql-codegen-sdk/dist/index.js
  • buro26-graphql-codegen-sdk/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (buro26-graphql-codegen-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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!