Skip to content

Commit 5abbcb3

Browse files
committed
Generalize the rule "Input Fields cannot reference inaccessible type"
1 parent 4f24192 commit 5abbcb3

File tree

1 file changed

+69
-59
lines changed

1 file changed

+69
-59
lines changed

spec/Section 4 -- Composition.md

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,6 +5079,75 @@ type AdminStats {
50795079
}
50805080
```
50815081

5082+
#### Reference To Inaccessible Type
5083+
5084+
**Error Code**
5085+
5086+
`REFERENCE_TO_INACCESSIBLE_TYPE`
5087+
5088+
**Formal Specification**
5089+
5090+
- Let {inputFields} be the set of all accessible fields of the input types in
5091+
the composed schema.
5092+
- For each {inputField} in {inputFields}:
5093+
- Let {namedType} be the named type that {inputField} references
5094+
- {namedType} must be accessible.
5095+
- Let {outputFields} be the set of all accessible fields of the output types in
5096+
the composed schema.
5097+
- For each {outputField} in {outputFields}:
5098+
- Let {namedType} be the named type that {outputField} references
5099+
- {namedType} must be accessible.
5100+
- Let {arguments} be the set of all accessible arguments of the output fields in
5101+
the composed schema.
5102+
- For each {argument} in {arguments}:
5103+
- Let {namedType} be the named type that {argument} references
5104+
- {namedType} must be accessible.
5105+
5106+
**Explanatory Text**
5107+
5108+
In a composed schema, fields and arguments must only reference types that are
5109+
exposed. This requirement guarantees that public types do not reference
5110+
inaccessible structures which are intended for internal use.
5111+
5112+
A valid case where a public input field references another public input type:
5113+
5114+
```graphql example
5115+
input Input1 {
5116+
field1: String!
5117+
field2: Input2
5118+
}
5119+
5120+
input Input2 {
5121+
field3: String
5122+
}
5123+
```
5124+
5125+
Another valid case is where the field is not exposed in the composed schema:
5126+
5127+
```graphql example
5128+
input Input1 {
5129+
field1: String!
5130+
field2: Input2 @inaccessible
5131+
}
5132+
5133+
input Input2 @inaccessible {
5134+
field3: String
5135+
}
5136+
```
5137+
5138+
An invalid case is when an input field references an inaccessible type:
5139+
5140+
```graphql counter-example
5141+
input Input1 {
5142+
field1: String!
5143+
field2: Input2!
5144+
}
5145+
5146+
input Input2 @inaccessible {
5147+
field3: String
5148+
}
5149+
```
5150+
50825151
### Validate Composite Types
50835152

50845153
#### Empty Merged Object Type
@@ -5650,65 +5719,6 @@ input BookFilter {
56505719
}
56515720
```
56525721

5653-
#### Input Fields cannot reference inaccessible type
5654-
5655-
**Error Code**
5656-
5657-
`INPUT_FIELD_REFERENCES_INACCESSIBLE_TYPE`
5658-
5659-
**Formal Specification**
5660-
5661-
- Let {fields} be the set of all fields of the input types in the composed
5662-
schema.
5663-
- For each {field} in {fields}:
5664-
- Let {namedType} be the named type that {field} references
5665-
- {namedType} must be in the composed schema.
5666-
5667-
**Explanatory Text**
5668-
5669-
In a composed schema, a field within an input type must only reference types
5670-
that are exposed. This requirement guarantees that public types do not reference
5671-
inaccessible structures which are intended for internal use.
5672-
5673-
A valid case where a public input field references another public input type:
5674-
5675-
```graphql example
5676-
input Input1 {
5677-
field1: String!
5678-
field2: Input2
5679-
}
5680-
5681-
input Input2 {
5682-
field3: String
5683-
}
5684-
```
5685-
5686-
Another valid case is where the field is not exposed in the composed schema:
5687-
5688-
```graphql example
5689-
input Input1 {
5690-
field1: String!
5691-
field2: Input2 @inaccessible
5692-
}
5693-
5694-
input Input2 @inaccessible {
5695-
field3: String
5696-
}
5697-
```
5698-
5699-
An invalid case is when an input field references an inaccessible type:
5700-
5701-
```graphql counter-example
5702-
input Input1 {
5703-
field1: String!
5704-
field2: Input2!
5705-
}
5706-
5707-
input Input2 @inaccessible {
5708-
field3: String
5709-
}
5710-
```
5711-
57125722
### Validate Enums
57135723

57145724
#### Empty Merged Enum Type

0 commit comments

Comments
 (0)