API refactor to make it harder to ignore errors #752
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #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.