@@ -66,6 +66,8 @@ const makeUtils = (
66
66
) ;
67
67
}
68
68
69
+ const defaultValue = build . options [ `pg${ Keyword } Default` ] || "NO" ;
70
+
69
71
const tables = rawTables
70
72
? ( rawTables as string [ ] ) . map ( ( t ) => {
71
73
const [ schemaOrTable , tableOnly , ...rest ] = t . split ( "." ) ;
@@ -219,6 +221,13 @@ const makeUtils = (
219
221
// any extra WHERE clauses.
220
222
return ;
221
223
}
224
+ // INHERIT is equivalent to defaultValue if there's no valid parent
225
+ const relevantSettingIfNotInherit =
226
+ relevantSetting !== "INHERIT"
227
+ ? relevantSetting
228
+ : defaultValue !== "INHERIT"
229
+ ? defaultValue
230
+ : "NO" ;
222
231
if (
223
232
capableOfInherit &&
224
233
relevantSetting === "INHERIT" &&
@@ -233,15 +242,11 @@ const makeUtils = (
233
242
sql ,
234
243
myAlias ,
235
244
) } is ${ localDetails . visibleFragment } )`;
236
- } else if (
237
- relevantSetting === "NO" ||
238
- // INHERIT is equivalent to NO if there's no valid parent
239
- relevantSetting === "INHERIT"
240
- ) {
245
+ } else if ( relevantSettingIfNotInherit === "NO" ) {
241
246
fragment = sql . fragment `${ localDetails . expression ( sql , myAlias ) } is ${
242
247
localDetails . visibleFragment
243
248
} `;
244
- } else if ( relevantSetting === "EXCLUSIVELY" ) {
249
+ } else if ( relevantSettingIfNotInherit === "EXCLUSIVELY" ) {
245
250
fragment = sql . fragment `${ localDetails . expression ( sql , myAlias ) } is ${
246
251
localDetails . invisibleFragment
247
252
} `;
@@ -362,6 +367,7 @@ const generator = (keyword = "archived"): GraphileEnginePlugin => {
362
367
const {
363
368
graphql : { GraphQLEnumType } ,
364
369
} = build ;
370
+ const defaultValue = build . options [ `pg${ Keyword } Default` ] || "NO" ;
365
371
build . newWithHooks (
366
372
GraphQLEnumType ,
367
373
{
@@ -381,7 +387,9 @@ const generator = (keyword = "archived"): GraphileEnginePlugin => {
381
387
value : "EXCLUSIVELY" ,
382
388
} ,
383
389
INHERIT : {
384
- description : `If there is a parent GraphQL record and it is ${ keyword } then this is equivalent to YES, in all other cases this is equivalent to NO.` ,
390
+ description : `If there is a parent GraphQL record and it is ${ keyword } then this is equivalent to YES, in all other cases this is equivalent to ${
391
+ defaultValue === "INHERIT" ? "NO" : defaultValue
392
+ } .`,
385
393
value : "INHERIT" ,
386
394
} ,
387
395
} ,
0 commit comments