@@ -122,7 +122,7 @@ describe('model with one id int', () => {
122122
123123 it ( 'object type description' , ( ) => {
124124 const decoratorArgument = classFile . getDecorators ( ) [ 0 ] . getStructure ( )
125- ? .arguments ?. [ 0 ] as string | undefined ;
125+ . arguments ?. [ 0 ] as string | undefined ;
126126 expect ( decoratorArgument ) . toMatch ( / d e s c r i p t i o n : \s * [ " ' ] U s e r r e a l l y [ " ' ] / ) ;
127127 } ) ;
128128
@@ -2081,6 +2081,48 @@ describe('compound index', () => {
20812081 } ) ;
20822082} ) ;
20832083
2084+ describe ( 'field type' , ( ) => {
2085+ describe ( 'it overwrites field type based on match expression' , ( ) => {
2086+ before ( async ( ) => {
2087+ ( { project, sourceFiles } = await testGenerate ( {
2088+ schema : `
2089+ model User {
2090+ id Int @id
2091+ /// @FieldType({ name: 'GraphQLJSONObject', from: 'graphql-scalars', namedImport: true, match: 'User{Create,Update}Input' })
2092+ profile Json
2093+ }
2094+ ` ,
2095+ options : [ `outputFilePattern = "{name}.{type}.ts"` ] ,
2096+ } ) ) ;
2097+ } ) ;
2098+
2099+ it ( 'should use default scalar type in model' , ( ) => {
2100+ setSourceFile ( 'user.model.ts' ) ;
2101+ expect ( t ( 'profile' ) ) . toEqual ( '() => GraphQLJSON' ) ;
2102+ } ) ;
2103+
2104+ it ( 'should use default scalar type in user-create-many.input' , ( ) => {
2105+ setSourceFile ( 'user-create-many.input.ts' ) ;
2106+ expect ( t ( 'profile' ) ) . toEqual ( '() => GraphQLJSON' ) ;
2107+ } ) ;
2108+
2109+ it ( 'user-create.input' , ( ) => {
2110+ setSourceFile ( 'user-create.input.ts' ) ;
2111+ expect ( t ( 'profile' ) ) . toEqual ( '() => GraphQLJSONObject' ) ;
2112+ } ) ;
2113+
2114+ it ( 'should use default scalar type in user-update-many-mutation.input' , ( ) => {
2115+ setSourceFile ( 'user-update-many-mutation.input.ts' ) ;
2116+ expect ( t ( 'profile' ) ) . toEqual ( '() => GraphQLJSON' ) ;
2117+ } ) ;
2118+
2119+ it ( 'user-update.input' , ( ) => {
2120+ setSourceFile ( 'user-update.input.ts' ) ;
2121+ expect ( t ( 'profile' ) ) . toEqual ( '() => GraphQLJSONObject' ) ;
2122+ } ) ;
2123+ } ) ;
2124+ } ) ;
2125+
20842126it ( 'fieldtype on groupby' , async ( ) => {
20852127 ( { project, sourceFiles } = await testGenerate ( {
20862128 schema : `
@@ -2097,6 +2139,49 @@ it('fieldtype on groupby', async () => {
20972139 expect ( t ( 'profile' ) ) . toEqual ( '() => GraphQLJSONObject' ) ;
20982140} ) ;
20992141
2142+ describe ( 'property type' , ( ) => {
2143+ describe ( 'it overwrites property type based on match expression' , ( ) => {
2144+ before ( async ( ) => {
2145+ ( { project, sourceFiles } = await testGenerate ( {
2146+ schema : `
2147+ model User {
2148+ id Int @id
2149+ /// @PropertyType({ name: 'JsonObject', from: 'type-fest', namedImport: true, match: 'User{Create,Update}Input' })
2150+ profile Json
2151+ }
2152+ ` ,
2153+ options : [ `outputFilePattern = "{name}.{type}.ts"` ] ,
2154+ } ) ) ;
2155+ } ) ;
2156+
2157+ it ( 'should use default scalar type in model' , ( ) => {
2158+ setSourceFile ( 'user.model.ts' ) ;
2159+ expect ( p ( 'profile' ) ?. type ) . toEqual ( 'any' ) ;
2160+ } ) ;
2161+
2162+ it ( 'should use default scalar type in user-create-many.input' , ( ) => {
2163+ setSourceFile ( 'user-create-many.input.ts' ) ;
2164+ expect ( p ( 'profile' ) ?. type ) . toEqual ( 'any' ) ;
2165+ } ) ;
2166+
2167+ it ( 'user-create.input' , ( ) => {
2168+ setSourceFile ( 'user-create.input.ts' ) ;
2169+ expect ( p ( 'profile' ) ?. type ) . toEqual ( 'JsonObject' ) ;
2170+
2171+ } ) ;
2172+
2173+ it ( 'should use default scalar type in user-update-many-mutation.input' , ( ) => {
2174+ setSourceFile ( 'user-update-many-mutation.input.ts' ) ;
2175+ expect ( p ( 'profile' ) ?. type ) . toEqual ( 'any' ) ;
2176+ } ) ;
2177+
2178+ it ( 'user-update.input' , ( ) => {
2179+ setSourceFile ( 'user-update.input.ts' ) ;
2180+ expect ( p ( 'profile' ) ?. type ) . toEqual ( 'JsonObject' ) ;
2181+ } ) ;
2182+ } ) ;
2183+ } ) ;
2184+
21002185it ( 'hidefield on groupby' , async ( ) => {
21012186 ( { project, sourceFiles } = await testGenerate ( {
21022187 schema : `
0 commit comments