Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port to apollo-compiler 1.0 beta (#4038)
Fixes #2710 # apollo-compiler background The public API of apollo-compiler 1.0 is almost completely different from 0.x. Notably it doesn’t have compiler objects anymore. Instead, users mainly manipulate: * `apollo_compiler::ast::Document` is the result of parsing one input file/string. May contain parse errors. Finding anything requires a linear scan of a `Vec` of top-level definitions. * `apollo_compiler::Schema` has stuff indexed by name, with GraphQL extensions "applied". Conversion from AST may record "build errors" (e.g. for a name collision). Stuff with errors (e.g. that second definition with the same name) may be missing in the main data structure. * `apollo_compiler::ExecutableDocument` similarly has operations and fragments indexed by name, has build errors, and may be missing stuff related to errors. Creating one requires `&Schema`, where it’ll find a field definition to associate with every field selection, and resolve the type of every selection set. `Schema` and `ExecutableDocument` have `validate` methods to run full GraphQL spec validation, but it needs to be called explicitly. A future beta will likely change the API to make it less easy to forget dealing with build errors or validation errors. # This PR Instead of creating and passing around a `Arc<Mutex<ApolloCompiler>>` for every GraphQL request, the Router now creates a `Arc<ParsedDocument>` which contains *both* an `ast::Document` and an `ExecutableDocument`. In a later PR we’ll want to run Rust validation early and have the rest of a request lifecycle only deal with `ExecutableDocument`, but as long as we rely on TypeScript validation some things still need to work at the AST level. ~~This PR starts as a draft because of remaining failing tests:~~ * `cargo test --lib` - [x] plugins::telemetry::metrics::apollo::test::apollo_metrics_validation_failure - [x] router::tests::schema_update_test - [x] spec::query::tests::reformat_response_data_best_effort * `cargo test --test integration_tests` - [x] api_schema_hides_field - [x] defer_path_with_disabled_config - [x] validation_errors_from_rust <!-- start metadata --> --- **Checklist** Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review. - [x] Changes are compatible[^1] - [ ] Documentation[^2] completed - [x] Performance impact assessed and acceptable - Tests added and passing[^3] - [ ] Unit Tests - [ ] Integration Tests - [ ] Manual Tests **Exceptions** *Note any exceptions here* **Notes** [^1]: It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. [^2]: Configuration is an important part of many changes. Where applicable please try to document configuration examples. [^3]: Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.
- Loading branch information