@@ -2057,113 +2057,6 @@ interface User {
2057
2057
2058
2058
### Validate Enums
2059
2059
2060
- #### Enum Type Default Value Uses Inaccessible Value
2061
-
2062
- **Error Code **
2063
-
2064
- `ENUM_TYPE_DEFAULT_VALUE_INACCESSIBLE `
2065
-
2066
- **Formal Specification **
2067
-
2068
- - {ValidateArgumentDefaultValues ()} must be true .
2069
- - {ValidateInputFieldDefaultValues ()} must be true .
2070
-
2071
- ValidateArgumentDefaultValues ():
2072
-
2073
- - Let {arguments } be all arguments of fields and directives across all source
2074
- schemas
2075
- - For each {argument } in {arguments }
2076
- - If {IsExposed (argument)} is true and has a default value :
2077
- - Let {defaultValue } be the default value of {argument }
2078
- - If not {ValidateDefaultValue (defaultValue)}
2079
- - return false
2080
- - return true
2081
-
2082
- ValidateInputFieldDefaultValues ():
2083
-
2084
- - Let {inputFields } be all input fields across all source schemas
2085
- - For each {inputField } in {inputFields }:
2086
- - If {IsExposed (inputField)} is true and {inputField } has a default value :
2087
- - Let {defaultValue } be the default value of {inputField }
2088
- - If {ValidateDefaultValue (defaultValue)} is false
2089
- - return false
2090
- - return true
2091
-
2092
- ValidateDefaultValue (defaultValue):
2093
-
2094
- - If {defaultValue } is a ListValue :
2095
- - For each {valueNode } in {defaultValue }:
2096
- - If {ValidateDefaultValue (valueNode)} is false
2097
- - return false
2098
- - If {defaultValue } is an ObjectValue :
2099
- - Let {objectFields } be a list of all fields of {defaultValue }
2100
- - Let {fields } be a list of all fields {objectFields } are referring to
2101
- - For each {field } in {fields }:
2102
- - If {IsExposed (field)} is false
2103
- - return false
2104
- - For each {objectField } in {objectFields }:
2105
- - Let {value } be the value of {objectField }
2106
- - return {ValidateDefaultValue (value)}
2107
- - If {defaultValue } is an EnumValue :
2108
- - If {IsExposed (defaultValue)} is false
2109
- - return false
2110
- - return true
2111
-
2112
- **Explanatory Text **
2113
-
2114
- This rule ensures that inaccessible enum values are not exposed in the composed
2115
- schema through default values. Output field arguments, input fields, and
2116
- directive arguments must only use enum values as their default value when not
2117
- annotated with the `@inaccessible ` directive.
2118
-
2119
- In this example the `FOO` value in the `Enum1` enum is not marked with
2120
- `@inaccessible `, hence it does not violate the rule.
2121
-
2122
- ```graphql
2123
- type Query {
2124
- field (type : Enum1 = FOO ): [Baz !]!
2125
- }
2126
-
2127
- enum Enum1 {
2128
- FOO
2129
- BAR
2130
- }
2131
- ```
2132
-
2133
- The following example violates this rule because the default value for the field
2134
- ` field ` in type ` Input1 ` references an enum value (` FOO ` ) that is marked as
2135
- ` @inaccessible ` .
2136
-
2137
- ``` graphql counter-example
2138
- type Query {
2139
- field (arg : Enum1 = FOO ): [Baz ! ]!
2140
- }
2141
-
2142
- input Input1 {
2143
- field : Enum1 = FOO
2144
- }
2145
-
2146
- directive @directive1 (arg : Enum1 = FOO ) on FIELD_DEFINITION
2147
-
2148
- enum Enum1 {
2149
- FOO @inaccessible
2150
- BAR
2151
- }
2152
- ```
2153
-
2154
- ``` graphql counter-example
2155
- type Query {
2156
- field (arg : Input1 = { field2 : " ERROR" }): [Baz ! ]!
2157
- }
2158
-
2159
- directive @directive1 (arg : Input1 = { field2 : " ERROR" }) on FIELD_DEFINITION
2160
-
2161
- input Input1 {
2162
- field1 : String
2163
- field2 : String @inaccessible
2164
- }
2165
- ```
2166
-
2167
2060
#### Enum Values Mismatch
2168
2061
2169
2062
**Error Code **
@@ -5637,6 +5530,117 @@ enum DeliveryStatus {
5637
5530
}
5638
5531
```
5639
5532
5533
+ #### Enum Type Default Value Uses Inaccessible Value
5534
+
5535
+ ** Error Code**
5536
+
5537
+ ` ENUM_TYPE_DEFAULT_VALUE_INACCESSIBLE `
5538
+
5539
+ ** Formal Specification**
5540
+
5541
+ - {ValidateArgumentDefaultValues()} must be true.
5542
+ - {ValidateInputFieldDefaultValues()} must be true.
5543
+
5544
+ ValidateArgumentDefaultValues():
5545
+
5546
+ - Let {arguments} be the set of all arguments of fields and directives the
5547
+ composed schema
5548
+ - For each {argument} in {arguments}
5549
+ - If {argument} has a default value:
5550
+ - Let {defaultValue} be the default value of {argument}
5551
+ - If not {ValidateDefaultValue(defaultValue)}
5552
+ - return false
5553
+ - return true
5554
+
5555
+ ValidateInputFieldDefaultValues():
5556
+
5557
+ - Let {inputFields} be the set of all input fields in the composed schema
5558
+ - For each {inputField} in {inputFields}:
5559
+ - If {inputField} has a default value:
5560
+ - Let {defaultValue} be the default value of {inputField}
5561
+ - If {ValidateDefaultValue(defaultValue)} is false
5562
+ - return false
5563
+ - return true
5564
+
5565
+ ValidateDefaultValue(defaultValue):
5566
+
5567
+ - If {defaultValue} is a ListValue:
5568
+ - For each {valueNode} in {defaultValue}:
5569
+ - If {ValidateDefaultValue(valueNode)} is false
5570
+ - return false
5571
+ - If {defaultValue} is an ObjectValue:
5572
+ - Let {objectFields} be a list of all fields of {defaultValue}
5573
+ - For each {objectField} in {objectFields}:
5574
+ - Let {value} be the value of {objectField}
5575
+ - return {ValidateDefaultValue(value)}
5576
+ - If {defaultValue} is an EnumValue:
5577
+ - If {enum} be the enum type of {defaultValue}
5578
+ - If {enum} does not have a value with the name of {defaultValue}
5579
+ - return false
5580
+ - return true
5581
+
5582
+ ** Explanatory Text**
5583
+
5584
+ This rule ensures that inaccessible enum values are not exposed in the composed
5585
+ schema through default values. Output field arguments, input fields, and
5586
+ directive arguments must only use enum values as their default value when not
5587
+ annotated with the ` @inaccessible ` directive.
5588
+
5589
+ In this example the ` FOO ` value in the ` Enum1 ` enum is not marked with
5590
+ ` @inaccessible ` , hence it does not violate the rule.
5591
+
5592
+ ``` graphql
5593
+ # Schema A
5594
+ type Query {
5595
+ field (type : Enum1 = FOO ): [Baz ! ]!
5596
+ }
5597
+
5598
+ enum Enum1 {
5599
+ FOO
5600
+ BAR
5601
+ }
5602
+ ```
5603
+
5604
+ The following example violates this rule because the default value for the field
5605
+ ` field ` in type ` Input1 ` references an enum value (` FOO ` ) that is marked as
5606
+ ` @inaccessible ` .
5607
+
5608
+ ``` graphql counter-example
5609
+ # Schema A
5610
+ type Query {
5611
+ field (arg : Enum1 = FOO ): [Baz ! ]!
5612
+ }
5613
+
5614
+ input Input1 {
5615
+ field : Enum1 = FOO
5616
+ }
5617
+
5618
+ directive @directive1 (arg : Enum1 = FOO ) on FIELD_DEFINITION
5619
+
5620
+ enum Enum1 {
5621
+ FOO @inaccessible
5622
+ BAR
5623
+ }
5624
+ ```
5625
+
5626
+ The following example violates this rule because the default value for the field
5627
+ ` field ` in type ` Input1 ` references an enum value (` FOO ` ) that is marked as
5628
+ ` @inaccessible ` .
5629
+
5630
+ ``` graphql counter-example
5631
+ # Schema A
5632
+ type Query {
5633
+ field (arg : Input1 = { field2 : " ERROR" }): [Baz ! ]!
5634
+ }
5635
+
5636
+ directive @directive1 (arg : Input1 = { field2 : " ERROR" }) on FIELD_DEFINITION
5637
+
5638
+ input Input1 {
5639
+ field1 : String
5640
+ field2 : String @inaccessible
5641
+ }
5642
+ ```
5643
+
5640
5644
### Validate Union Types
5641
5645
5642
5646
#### Empty Merged Union Type
0 commit comments