Skip to content

Commit

Permalink
partialy fix Bugs with yup v1 and arrays of non nullable Code-Hex#359
Browse files Browse the repository at this point in the history
  • Loading branch information
erwan-joly committed Jun 8, 2023
1 parent 7a7e9ed commit 6d29391
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions example/test.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ type Guest {

union UserKind = Admin | Guest

type InnerType {
testScalar: MyScalar!
}

type OuterType {
inner: InnerType
}

scalar MyScalar

type User {
id: ID
name: String
Expand Down
4 changes: 2 additions & 2 deletions src/yup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ export const YupSchemaVisitor = (schema: GraphQLSchema, config: ValidationSchema
return new DeclarationBlock({})
.export()
.asKind('function')
.withName(`${name}Schema(): yup.ObjectSchema<${name}>`)
.withName(`${name}Schema(): yup.Schema`)
.withBlock(
[
indent(`return yup.object({`),
indent(`__typename: yup.string<'${node.name.value}'>().optional(),`, 2),
shape,
indent('})'),
indent(`}) satisfies yup.ObjectSchema<${name}>`),
].join('\n')
).string;
}),
Expand Down

0 comments on commit 6d29391

Please sign in to comment.