ast::Document, Schema, and ExecutableDocument not longer contain potential errors that users need to check separately.
Instead, various constructors and methods now return a Result, with the Err case containing both both errors and a maybe-incomplete value.
Change validate methods of Schema and ExecutableDocument to take ownership of self. On success they return the schema or document (unmodified) wrapped in a Valid<_> marker type, which is immutable.
Change ExecutableDocument to require a &Valid<Schema> instead of &Schema, forcing callers to either run validation or opt out explicitly with Valid::assert_valid.
Make parse_mixed and to_mixed validate both the schema and document. Rename them with a _validate suffix.
Corresponding changes to all of the above in Parser method signatures
Remove ast::Document::check_parse_errors: parse errors are now encoded in the return value of parse.
Remove ast::Document::to_schema_builder. Use SchemaBuilder::add_ast instead.
Move items from the crate top-level to apollo_compiler::validation:
Diagnostic
DiagnosticList
FileId
NodeLocation
Move items from the crate top-level to apollo_compiler::execution:
Add parse_and_validate constructors for Schema and ExecutableDocument: when mutating isn’t needed after parsing, this returns an immutable Valid<_> value in one step.
Fixes https://github.com/apollographql/apollo-rs/issues/709
BREAKING
ast::Document
,Schema
, andExecutableDocument
not longer contain potential errors that users need to check separately.Result
, with theErr
case containing both both errors and a maybe-incomplete value.validate
methods ofSchema
andExecutableDocument
to take ownership ofself
. On success they return the schema or document (unmodified) wrapped in aValid<_>
marker type, which is immutable.ExecutableDocument
to require a&Valid<Schema>
instead of&Schema
, forcing callers to either run validation or opt out explicitly withValid::assert_valid
.parse_mixed
andto_mixed
validate both the schema and document. Rename them with a_validate
suffix.Parser
method signaturesast::Document::check_parse_errors
: parse errors are now encoded in the return value ofparse
.ast::Document::to_schema_builder
. UseSchemaBuilder::add_ast
instead.apollo_compiler::validation
:Diagnostic
DiagnosticList
FileId
NodeLocation
apollo_compiler::execution
:GraphQLError
GraphQLLocation
Highlight of signature changes:
Features
parse_and_validate
constructors forSchema
andExecutableDocument
: when mutating isn’t needed after parsing, this returns an immutableValid<_>
value in one step.