-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apollo-parser, apollo-compiler): support parsing and validating …
…FieldSet (#685) * feat(apollo-parser): parser allows parsing selection sets only In order to support `FieldSet` work in `federation-next`, we'd like to allow specific `field_set` parsing. It can be accessed after constructing the parser by calling `.parse_fieldset`. ```rust let source = r#"{ a }"#; let parser = Parser::new(source); let cst: SyntaxTree<cst::SelectionSet> = parser.parse_fieldset(); let errors = cst.errors().collect::<Vec<_>>(); assert_eq!(errors.len(), 0); let sel_set: cst::SelectionSet = cst.selection_set(); let _ = sel_set.selections().map(|sel| { if let cst::Selection::Field(f) = sel { assert_eq!(f.name().unwrap().text().as_ref(), "a") } }); ``` * rename parse_fieldset to parse_selection_set This follows specification naming more closely, rather than aligning the parser to federation implementation * feat(parser): allow field sets to not have opening braces to support `@requires` Because field sets may or may not have opening braces, we are no longer strictly following the graphql specification. As part of this change, the API points referencing parsing `selection_set` are now renamed to `field_set` * add parse_field_set to compiler API This commit creates several wrapper types to handle FieldSet. - apollo-compiler's parser endpoint now has `parse_field_set` public API and an internal `parse_field_set_ast`, - executable document now has a `FieldSet` struct that allows us to store build errors along with the actual selection set - internal compiler's ast now has an implementation for `FieldSet` with source information for diagnostics and the actual selection set - it additionally implements a `FieldSet::from_cst` and `FieldSet::to_field_set` (which converts this to executable HIR `FieldSet` type) * Compiler API for FieldSet parsing and validation * Add a default to SyntaxTree’s new type parameter, for semver-compat https://rust-lang.github.io/rfcs/1105-api-evolution.html#minor-change-adding-a-defaulted-type-parameter * Changelog * Add basic FieldSet validation tests * slight edits to changelog --------- Co-authored-by: Simon Sapin <[email protected]>
- Loading branch information
1 parent
5065bc7
commit da57a9d
Showing
17 changed files
with
432 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.