Releases: apollographql/apollo-rs
[email protected]
Fixes
- apply recursion limit where needed, reduce its default from 4096 to 500 - SimonSapin, pull/662
The limit was only tracked for nested selection sets, but the parser turns out
to use recursion in other cases too. Issue 666 tracks reducing them.
Stack overflow was observed with little more than 2000
nesting levels or repetitions in the new test.
Defaulting to a quarter of that leaves a comfortable margin. - fix various lexer bugs - SimonSapin, pull/646, pull/652
The lexer was too permissive in emitting tokens instead of errors
in various cases around numbers, strings, and EOF. - fix panic on surrogate code points in unicode escape sequences - SimonSapin, issue/608, pull/658
[email protected]
Features
-
expose line/column location and JSON format from diagnostics, by goto-bus-stop in pull/668
You can now use
diagnostic.get_line_column()
to access the line/column number where a validation error occurred.diagnostic.to_json()
returns a GraphQL error structure that's serializable with serde, matching the JSON error format.let diagnostics = compiler.db.validate(); let errors = diagnostics.into_iter().map(ApolloDiagnostic::to_json).collect::<Vec<_>>(); let error_response = serde_json::to_string(&serde_json::json!({ "errors": errors, }))?;
-
improve validation error summaries, by goto-bus-stop in pull/674
Adds more context and a more consistent voice to the "main" message for validation errors. They are now concise,
matter-of-fact descriptions of the problem. Information about how to solve the problem is usually already provided
by labels and notes on the diagnostic.- operation
getName
is defined multiple times - interface
NamedEntity
implements itself
The primary use case for this is to make
diagnostic.data.to_string()
return a useful message for text-only error
reports, like in JSON responses. The JSON format for diagnostics uses these new messages. - operation
[email protected]
BREAKING
- rename
ast
tocst
- SimonSapin, commit/f30642aa
The Rowan-based typed syntax tree emitted by the parser used to be called
Abstract Syntax Tree (AST) but is in fact not very abstract: it preserves
text input losslessly, and all tree leaves are string-based tokens.
This renames it to Concrete Syntax Tree (CST) and renames various APIs accordingly.
This leaves the name available for a new AST in apollo-compiler 1.0.
[email protected]
1.0.0-beta.1 - 2023-10-05
BREAKING
Compared to 0.11, version 1.0 is a near-complete rewrite of the library and revamp of the public API. While in beta, there may still be breaking changes (though not as dramatic) until 1.0.0 “final”. If using a beta version, we recommend specifying an exact dependency in Cargo.toml
:
apollo-compiler = "=1.0.0-beta.1"
Features
The API is now centered on Schema
and ExecutableDocument
types. Users no longer need to create a compiler, add inputs to it, and track them by ID. Validation is now a method of these types, and returns a Result
to indicate errors.
These types are serializable (through Display
, .to_string()
, and a .serialize()
config builder), integrating the functionality of the apollo-encoder crate.
They are also mutable, and can be created programmatically out of thin air. Node<T>
is a thread-safe reference-counted smart pointer
that provides structural sharing and copy-on-write semantics.
[email protected]
Fixes
- fixes to conversions from AST string nodes to Rust Strings - goto-bus-stop, pull/633, issue/609, issue/611
This fix affects theString::from(ast::StringValue)
conversion function, which returns the contents of a GraphQL string node.
"\""
was previously interpreted as just a backslash, now it is correctly interpreted as a double quote. For block strings, indentation is stripped as required by the spec.
[email protected]
Features
-
Add
validate_standalone_executable
function to validate an executable document without access to a schema, by goto-bus-stop in pull/631, issue/629This runs just those validations that can be done on operations without knowing the types of things.
let compiler = ApolloCompiler::new(); let file_id = compiler.add_executable(r#" { user { ...userData } } "#, "query.graphql"); let diagnostics = compiler.db.validate_standalone_executable(file_id); // Complains about `userData` fragment not existing, but does not complain about `user` being an unknown query.
Fixes
-
validate input value types, by goto-bus-stop in pull/642
This fixes an oversight in the validation rules implemented by
compiler.db.validate()
. Previously, incorrect
types on input values and arguments were not reported:type ObjectType { id: ID! } input InputObject { # accepted in <= 0.11.1, reports "TypeThatDoesNotExist is not in scope" in 0.11.2 property: TypeThatDoesNotExist # accepted in <= 0.11.1, reports "ObjectType is not an input type" in 0.11.2 inputType: ObjectType }
[email protected]
Fixes
- fix lexing escape-sequence-like text in block strings - goto-bus-stop, pull/638, issue/632
Fixes a regression in 0.6.0 that could cause apollo-parser to reject valid input if a
block string contained backslashes. Block strings do not support escape sequences so
backslashes are normally literal, but 0.6.0 tried to lex them as escape sequences,
which could be invalid (eg.\W
is not a supported escape sequence).
Now block strings are lexed like in 0.5.3. Only the\"""
sequence is treated as an
escape sequence.
[email protected]
Features
- disable colours in diagnostics output if the terminal is not interactive, by EverlastingBugstopper in pull/628, issue/499
[email protected]
BREAKING
-
[email protected] - goto-bus-stop, pull/621
This updates the version of
apollo-parser
required by theTryFrom
implementations in this crate. -
[email protected] - goto-bus-stop, pull/623
This updates the version of
apollo-encoder
required by theFrom
implementations in this crate.
[email protected]
Features
- zero-alloc lexer - allancalix, pull/322
Rewrites the lexer to avoid allocating for each token. Synthetic benchmarks
show about a 25% performance improvement to the parser as a whole.
Fixes
-
fix token limit edge case - goto-bus-stop, pull/619, issue/610
token_limit
now includes the EOF token. In the past you could get
token_limit + 1
tokens out of the lexer if the token at the limit was the
EOF token, but now it really always stops attoken_limit
. -
create EOF token with empty data - allancalix, pull/591
Makes consuming the token stream's data produce an identical string to the
original input of the lexer.