1.0.12 • Published 2 years ago

graphql-codegen-yup v1.0.12

Weekly downloads
-
License
ISC
Repository
-
Last release
2 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

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago