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.
BREAKING
API refactor to make it harder to ignore errors - SimonSapin,
pull/752 fixing issue/709:
ast::Document
,Schema
, andExecutableDocument
not longer contain potential errorsthat users need to check separately.
Result
,with the
Err
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 a
Valid<_>
marker type,which is immutable.
ExecutableDocument
to require a&Valid<Schema>
instead of&Schema
,forcing callers to either run validation or opt out explicitly with
Valid::assume_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 of
parse
.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
Add
parse_and_validate
constructors forSchema
andExecutableDocument
- SimonSapin,pull/752:
when mutating isn’t needed after parsing,
this returns an immutable
Valid<_>
value in one step.Implement serde
Serialize
andDeserialize
for some AST types - SimonSapin, pull/760:Node
NodeStr
Name
IntValue
FloatValue
Value
Type
Source locations are not preserved through serialization.
Add
ast::Definition::as_*() -> Option<&_>
methods for each variant - SimonSapin, pull/760Serialize (to GraphQL) multi-line strings as block strings - SimonSapin, pull/724:
Example before:
After:
Fixes
Limit recursion in validation - goto-bus-stop, pull/748 fixing issue/742
Validation now bails out of very long chains of definitions that refer to each other,
even if they don't strictly form a cycle. These could previously cause extremely long validation
times or stack overflows.
The limit for input objects and directives is set at 32. For fragments, the limit is set at 100.
Based on our datasets, real-world documents don't come anywhere close to this.