@@ -1198,7 +1198,7 @@ describe("validation 2.0", () => {
1198
1198
expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "updatedAt" , "@default" , "value" ] ) ;
1199
1199
} ) ;
1200
1200
1201
- test ( "@default on datetime must be valid datetime correct " , ( ) => {
1201
+ test ( "@default on DateTime must be valid, check with valid value " , ( ) => {
1202
1202
const doc = gql `
1203
1203
type User @node {
1204
1204
updatedAt: DateTime @default(value: "2023-07-06T09:45:11.336Z")
@@ -1215,6 +1215,92 @@ describe("validation 2.0", () => {
1215
1215
expect ( executeValidate ) . not . toThrow ( ) ;
1216
1216
} ) ;
1217
1217
1218
+ test ( "@default on LocalDateTime must be valid, check with valid value" , ( ) => {
1219
+ const doc = gql `
1220
+ type User @node {
1221
+ updatedAt: LocalDateTime @default(value: "2023-07-06T09:45:11.336")
1222
+ }
1223
+ ` ;
1224
+
1225
+ const executeValidate = ( ) =>
1226
+ validateDocument ( {
1227
+ document : doc ,
1228
+ additionalDefinitions,
1229
+ features : { } ,
1230
+ } ) ;
1231
+
1232
+ expect ( executeValidate ) . not . toThrow ( ) ;
1233
+ } ) ;
1234
+
1235
+ test ( "@default on Time must be valid, check with valid value" , ( ) => {
1236
+ const doc = gql `
1237
+ type User @node {
1238
+ updatedAt: Time @default(value: "09:45:11.336Z")
1239
+ }
1240
+ ` ;
1241
+
1242
+ const executeValidate = ( ) =>
1243
+ validateDocument ( {
1244
+ document : doc ,
1245
+ additionalDefinitions,
1246
+ features : { } ,
1247
+ } ) ;
1248
+
1249
+ expect ( executeValidate ) . not . toThrow ( ) ;
1250
+ } ) ;
1251
+
1252
+ test ( "@default on LocalTime must be valid, check with valid value" , ( ) => {
1253
+ const doc = gql `
1254
+ type User @node {
1255
+ updatedAt: LocalTime @default(value: "09:45:11.336")
1256
+ }
1257
+ ` ;
1258
+
1259
+ const executeValidate = ( ) =>
1260
+ validateDocument ( {
1261
+ document : doc ,
1262
+ additionalDefinitions,
1263
+ features : { } ,
1264
+ } ) ;
1265
+
1266
+ expect ( executeValidate ) . not . toThrow ( ) ;
1267
+ } ) ;
1268
+
1269
+ test ( "@default on Date must be valid, check with valid value" , ( ) => {
1270
+ const doc = gql `
1271
+ type User @node {
1272
+ updatedAt: Date @default(value: "2023-07-06")
1273
+ }
1274
+ ` ;
1275
+
1276
+ const executeValidate = ( ) =>
1277
+ validateDocument ( {
1278
+ document : doc ,
1279
+ additionalDefinitions,
1280
+ features : { } ,
1281
+ } ) ;
1282
+
1283
+ expect ( executeValidate ) . not . toThrow ( ) ;
1284
+ } ) ;
1285
+
1286
+ test ( "@default on BigInt must be valid, check with valid value" , ( ) => {
1287
+ const doc = gql `
1288
+ type User @node {
1289
+ bigintnumber: BigInt @default(value: 0)
1290
+ bigintstring: BigInt @default(value: "0")
1291
+ }
1292
+ ` ;
1293
+
1294
+ const executeValidate = ( ) =>
1295
+ validateDocument ( {
1296
+ document : doc ,
1297
+ additionalDefinitions,
1298
+ features : { } ,
1299
+ } ) ;
1300
+
1301
+ expect ( executeValidate ) . not . toThrow ( ) ;
1302
+ } ) ;
1303
+
1218
1304
test ( "@default on enum must be enum" , ( ) => {
1219
1305
const enumTypes = gql `
1220
1306
enum Status {
@@ -1460,11 +1546,7 @@ describe("validation 2.0", () => {
1460
1546
features : { } ,
1461
1547
} ) ;
1462
1548
1463
- const errors = getError ( executeValidate ) ;
1464
- expect ( errors ) . toHaveLength ( 1 ) ;
1465
- expect ( errors [ 0 ] ) . not . toBeInstanceOf ( NoErrorThrownError ) ;
1466
- expect ( errors [ 0 ] ) . toHaveProperty ( "message" , "@default.value on Float fields must be of type Float" ) ;
1467
- expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "avg" , "@default" , "value" ] ) ;
1549
+ expect ( executeValidate ) . not . toThrow ( ) ;
1468
1550
} ) ;
1469
1551
1470
1552
test ( "@default on float must be float correct" , ( ) => {
@@ -1498,14 +1580,7 @@ describe("validation 2.0", () => {
1498
1580
features : { } ,
1499
1581
} ) ;
1500
1582
1501
- const errors = getError ( executeValidate ) ;
1502
- expect ( errors ) . toHaveLength ( 1 ) ;
1503
- expect ( errors [ 0 ] ) . not . toBeInstanceOf ( NoErrorThrownError ) ;
1504
- expect ( errors [ 0 ] ) . toHaveProperty (
1505
- "message" ,
1506
- "@default.value on Float list fields must be a list of Float values"
1507
- ) ;
1508
- expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "avgs" , "@default" , "value" ] ) ;
1583
+ expect ( executeValidate ) . not . toThrow ( ) ;
1509
1584
} ) ;
1510
1585
1511
1586
test ( "@default on float list must be list of float values correct" , ( ) => {
@@ -1779,8 +1854,11 @@ describe("validation 2.0", () => {
1779
1854
const errors = getError ( executeValidate ) ;
1780
1855
expect ( errors ) . toHaveLength ( 1 ) ;
1781
1856
expect ( errors [ 0 ] ) . not . toBeInstanceOf ( NoErrorThrownError ) ;
1782
- expect ( errors [ 0 ] ) . toHaveProperty ( "message" , "@default is not supported by Spatial types." ) ;
1783
- expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "updatedAt" , "@default" , "value" ] ) ;
1857
+ expect ( errors [ 0 ] ) . toHaveProperty (
1858
+ "message" ,
1859
+ "@default directive can only be used on fields of type Int, Float, String, Boolean, ID, BigInt, DateTime, Date, Time, LocalDateTime or LocalTime."
1860
+ ) ;
1861
+ expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "updatedAt" , "@default" ] ) ;
1784
1862
} ) ;
1785
1863
1786
1864
test ( "@default only supported on scalar types" , ( ) => {
@@ -1805,7 +1883,7 @@ describe("validation 2.0", () => {
1805
1883
expect ( errors [ 0 ] ) . not . toBeInstanceOf ( NoErrorThrownError ) ;
1806
1884
expect ( errors [ 0 ] ) . toHaveProperty (
1807
1885
"message" ,
1808
- "@default directive can only be used on Temporal types and types: Int | Float | String | Boolean | ID | Enum "
1886
+ "@default directive can only be used on fields of type Int, Float, String, Boolean, ID, BigInt, DateTime, Date, Time, LocalDateTime or LocalTime. "
1809
1887
) ;
1810
1888
expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "post" , "@default" ] ) ;
1811
1889
} ) ;
@@ -2092,11 +2170,7 @@ describe("validation 2.0", () => {
2092
2170
features : { } ,
2093
2171
} ) ;
2094
2172
2095
- const errors = getError ( executeValidate ) ;
2096
- expect ( errors ) . toHaveLength ( 1 ) ;
2097
- expect ( errors [ 0 ] ) . not . toBeInstanceOf ( NoErrorThrownError ) ;
2098
- expect ( errors [ 0 ] ) . toHaveProperty ( "message" , "@coalesce.value on Float fields must be of type Float" ) ;
2099
- expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "avg" , "@coalesce" , "value" ] ) ;
2173
+ expect ( executeValidate ) . not . toThrow ( ) ;
2100
2174
} ) ;
2101
2175
2102
2176
test ( "@coalesce on float must be float correct" , ( ) => {
@@ -2130,14 +2204,7 @@ describe("validation 2.0", () => {
2130
2204
features : { } ,
2131
2205
} ) ;
2132
2206
2133
- const errors = getError ( executeValidate ) ;
2134
- expect ( errors ) . toHaveLength ( 1 ) ;
2135
- expect ( errors [ 0 ] ) . not . toBeInstanceOf ( NoErrorThrownError ) ;
2136
- expect ( errors [ 0 ] ) . toHaveProperty (
2137
- "message" ,
2138
- "@coalesce.value on Float list fields must be a list of Float values"
2139
- ) ;
2140
- expect ( errors [ 0 ] ) . toHaveProperty ( "path" , [ "User" , "avgs" , "@coalesce" , "value" ] ) ;
2207
+ expect ( executeValidate ) . not . toThrow ( ) ;
2141
2208
} ) ;
2142
2209
2143
2210
test ( "@coalesce on float list must be list of float values correct" , ( ) => {
0 commit comments