1.0.12 • Published 3 years ago

graphql-codegen-yup v1.0.12

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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.

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago