Skip to content

Commit f9186c1

Browse files
committed
Add formal specifications
1 parent d66169d commit f9186c1

1 file changed

Lines changed: 74 additions & 6 deletions

File tree

spec/Section 4 -- Composition.md

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,22 @@ interface Node {
736736

737737
`IS_INVALID_SYNTAX`
738738

739+
**Severity**
740+
741+
ERROR
742+
739743
**Formal Specification**
740744

741-
(to be completed)
745+
- Let {compositeTypes} be the set of all composite types in the schema.
746+
- For each {composite} in {compositeTypes}:
747+
- Let {fields} be the set of fields on {composite}.
748+
- Let {arguments} be the set of all arguments on {fields}.
749+
- For each {argument} in {arguments}:
750+
- If {argument} is **not** annotated with `@is`:
751+
- Continue
752+
- Let {fieldArg} be the string value of the `field` argument of the `@is`
753+
directive on {argument}.
754+
- {fieldArg} must be be parsable as a valid selection map
742755

743756
**Explanatory Text**
744757

@@ -783,9 +796,24 @@ type Person {
783796

784797
`IS_INVALID_FIELD_TYPE`
785798

799+
**Severity**
800+
801+
ERROR
802+
786803
**Formal Specification**
787804

788-
(to be completed)
805+
- Let {schema} be the source schema to validate.
806+
- Let {compositeTypes} be the set of all composite types in {schema}.
807+
- For each {composite} in {compositeTypes}:
808+
- Let {fields} be the set of fields on {composite}.
809+
- Let {arguments} be the set of all arguments on {fields}.
810+
- For each {argument} in {arguments}:
811+
- If {argument} is **not** annotated with `@is`:
812+
- Continue
813+
- Let {fieldArg} be the value of the `field` argument of the `@is` directive
814+
on {argument}.
815+
- If {fieldArg} is **not** a string:
816+
- Produce an `IS_INVALID_FIELD_TYPE` error.
789817

790818
**Explanatory Text**
791819

@@ -831,9 +859,22 @@ type Person {
831859

832860
`IS_INVALID_USAGE`
833861

862+
**Severity**
863+
864+
ERROR
865+
834866
**Formal Specification**
835867

836-
(to be completed)
868+
- Let {schema} be the source schema to validate.
869+
- Let {compositeTypes} be the set of all composite types in {schema}.
870+
- For each {compositeType} in {compositeTypes}:
871+
- Let {fields} be the set of fields on {compositeType}.
872+
- For each {field} in {fields}:
873+
- Let {arguments} be the set of all arguments on {field}.
874+
- For each {argument} in {arguments}:
875+
- If {argument} is **not** annotated with `@is`:
876+
- Continue
877+
- {field} must be annotated with `@lookup`
837878

838879
**Explanatory Text**
839880

@@ -5867,15 +5908,42 @@ type Product @inaccessible {
58675908

58685909
### Validate Is Directives
58695910

5870-
#### Is Invalid Field
5911+
#### Is Invalid Fields
58715912

58725913
**Error Code**
58735914

5874-
`IS_INVALID_FIELD`
5915+
`IS_INVALID_FIELDS`
5916+
5917+
**Severity**
5918+
5919+
ERROR
58755920

58765921
**Formal Specification**
58775922

5878-
(to be completed)
5923+
- Let {schemas} be all source schemas.
5924+
- Let {compositeTypes} be the set of all composite types in {schemas}.
5925+
- For each {composite} in {compositeTypes}:
5926+
- Let {fields} be the set of fields on {composite}.
5927+
- Let {arguments} be the set of all arguments on {fields}.
5928+
- For each {argument} in {arguments}:
5929+
- If {argument} is **not** annotated with `@is`:
5930+
- Continue
5931+
- Let {schema} be the schema that defines {argument}.
5932+
- Let {declaringField} be the field that defines {argument}.
5933+
- Let {declaringType} be the type that defines {declaringField}.
5934+
- Let {otherSchemas} be the set of all {schemas} excluding {schema}.
5935+
- Let {fieldArg} be the string value of the `field` argument of the `@is`
5936+
directive on {argument}.
5937+
- Let {parsedFieldArg} be the parsed selection map from {fieldArg}.
5938+
- The parsed selection map {parsedFieldArg} must satisfy the validation
5939+
rules defined in Appendix A, Section 6.3, using:
5940+
- {declaringType} as the initial root type.
5941+
- The combined schema context formed by the union of {otherSchemas} as the
5942+
schema context except all fields marked as `@internal`
5943+
- Validation succeeds if each required field selection path can be
5944+
resolved across this combined schema context. Individual fields in the
5945+
selection may exist in different schemas; it is not required that all
5946+
fields referenced by {parsedFieldArg} reside within a single schema.
58795947

58805948
**Explanatory Text**
58815949

0 commit comments

Comments
 (0)