File tree Expand file tree Collapse file tree 3 files changed +3
-46
lines changed Expand file tree Collapse file tree 3 files changed +3
-46
lines changed Original file line number Diff line number Diff line change @@ -74,17 +74,13 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
7474 */
7575 enumsAsTypes ?: boolean ;
7676 /**
77- * @description this is for yup schema. use this when you specified `schema: yup`
78- */
79- yup ?: YupSchemaPluginConfig ;
80- /**
81- * @description Generates yup schema as strict.
77+ * @description Generates validation schema with more API based on directive schema.
8278 * @exampleMarkdown
8379 * ```yml
8480 * generates:
8581 * path/to/file.ts:
8682 * plugins:
87- * - graphql-codegen-validation-schema:
83+ * - graphql-codegen-validation-schema
8884 * config:
8985 * schema: yup
9086 * directives:
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ const generateNameNodeYupSchema = (
185185 }
186186
187187 const primitive = yup4Scalar ( tsVisitor , node . value ) ;
188- return config . yup ?. strict ? ` ${ primitive } .strict(true)` : primitive ;
188+ return primitive ;
189189} ;
190190
191191const maybeLazy = ( type : TypeNode , schema : string ) : string => {
Original file line number Diff line number Diff line change @@ -214,43 +214,4 @@ describe("yup", () => {
214214 "export const PageTypeSchema = yup.mixed().oneOf(['PUBLIC', 'BASIC_AUTH'])"
215215 ) ;
216216 } ) ;
217- it ( "with yup.strict" , async ( ) => {
218- const schema = buildSchema ( /* GraphQL */ `
219- input PrimitiveInput {
220- a: ID
221- b: String
222- c: Boolean
223- d: Int
224- e: Float
225- f: F!
226- }
227-
228- input F {
229- a: String!
230- }
231- ` ) ;
232- const result = await plugin (
233- schema ,
234- [ ] ,
235- {
236- yup : {
237- strict : true ,
238- } ,
239- } ,
240- { }
241- ) ;
242- const wantContains = [
243- "export function PrimitiveInputSchema(): yup.SchemaOf<PrimitiveInput>" ,
244- "a: yup.string().strict(true)," ,
245- "b: yup.string().strict(true)," ,
246- "c: yup.boolean().strict(true)," ,
247- "d: yup.number().strict(true)," ,
248- "e: yup.number().strict(true)," ,
249- "f: FSchema().defined()" ,
250- "a: yup.string().strict(true).defined()" , // for FSchema
251- ] ;
252- for ( const wantContain of wantContains ) {
253- expect ( result . content ) . toContain ( wantContain ) ;
254- }
255- } ) ;
256217} ) ;
You can’t perform that action at this time.
0 commit comments