graphql-codegen-yup
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

graphql-codegen-yup

Graphql codegen plugin for yup schema generation.

Links

Github

https://github.com/strynkow/graphql-codegen-yup/tree/master

NPM

https://www.npmjs.com/package/graphql-codegen-yup

Overview

The TLDR here is that I was looking at graphql-codegen-typescript-validation-schema, but it didn't really support fragments, and that caused it to break on object types. I was going to add that, but zod was incorrectly erroring on types (seemed to be a zod issue), so I just added my own project for yup.

I plan on actively maintaining this. Feel free to contribute.

Install

NPM

npm i --save-dev graphql-codegen-yup

Yarn

yarn add -D graphql-codegen-yup

Use

Once you've installed the package, you can add it to your current codegen config in the following manner.

generates:
  path/to/graphql.ts:
    plugins:
      - typescript
      - graphql-codegen-yup # add this line.
    config:
      # For overwriting any schemas with specific values.
      scalarSchemas:
        JSON: yup.object()
        Date: yup.date()
        Email: yup.string().email()

You can see test cases and examples by browsing around the /tests folder. /tests/__snapshots__ contains the outputs of running this on those schemas.

Package Sidebar

Install

npm i graphql-codegen-yup

Weekly Downloads

3

Version

1.0.12

License

ISC

Unpacked Size

72.2 kB

Total Files

22

Last publish

Collaborators

  • orangeseven7