apollo-rs
apollo-rs copied to clipboard
semantic analysis: validate Input Values in Document
Description
Validate the operation definition and add related methods to the SourceDatabase.
Related Issues, #144, #147
Specification
The following separate Input Value types are to be validated in this issue:
- [ ] String Value
- [ ] List Value
- [ ] Input Object Value
- [ ] Variable
- [ ] Named Type
- [ ] Enum
String Value Validation
- Documentation in spec
Semantic processing
String values have to be processed as per this breakdown in spec. While working on this issue, we ought to also figure out at what stage this processing happens (before or after validation), and whether or not this modification persists in the Source Database. The processing should definitely not modify the underlying AST.
List Value Validation
- Documentation in spec
Semantic processing
String values have to be processed as per this breakdown in spec.
Input Value Object Validation
- Documentation in spec
Semantic processing
String values have to be processed as per this breakdown in spec.
Variable Validation
- Documentation in spec
1. Must not be defined as a constant to be used as an input value (e.g. is variable in scope?)
(spec)
Hints
- show where the variable is already defined as a constant
Additions to Source Database
- a notion of scope: what are current variables in a given operation definition?
Vec<DefinedVariableNames>
2. Must be defined in top-level operation definition
Hints
- show where the variable can be added in top-level operation
Additions to Source Database
- current variables in use →
Vec<VariablesInUse>
(different than defined variables)
3. A variable must be defined by top level operation when in use by an operation's fragment
(spec)
Hints
- show where the variable can be added in top-level operation
Additions to Source Database
- a notion of scope: what are current variables in a given operation definition?
Vec<DefinedVariableNames>
Named Type Validation
- Documentation in spec
1. must be defined in schema
Additions to Source Database
- all scalars →
Vec<ScalarTypeNames>
- all enums →
Vec<EnumTypeNames>
- all objects →
Vec<InputObjectTypeNames>