Releases: apollographql/apollo-rs
[email protected]
Fixes
-
fix panics when parsing type names with syntax errors - goto-bus-stop, pull/381
For example,
field: []
does not panic anymore. Instead it produces a syntax error and an incomplete List type. -
continue parsing after a syntax error in an object type field - goto-bus-stop, pull/381
type A { fieldA: [] # ← has error, missing item type fieldB: Int fieldC: Int }
Previously fieldB and fieldC would not be parsed, now they are.
[email protected]
Features
- add new APIs - SimonSapin, pull/382
db.find_enum_by_name()
to look up anEnumTypeDefinition
.directive.argument_by_name()
to look up the value of an argument to a directive call.scalar_type.is_built_in()
to check if aScalarTypeDefinition
is defined by the GraphQL spec rather than the schema text.enum_value.directives()
to access the directives used on an enum value.hir::Float
is nowCopy
so it can be passed around more easily; usehir_float.get()
to access the underlyingf64
orhir_float.to_i32_checked()
to convert to ani32
.
Fixes
-
do not panic when creating HIR from a parse tree with syntax errors - goto-bus-stop, pull/381
When using the compiler, nodes with syntax errors in them are ignored. As syntax errors are returned
from the parser, you can still tell that something is wrong. The compiler just won't crash the whole
program anymore.
[email protected]
This is a re-publish of 0.3.0 with fixed dependency versions.
[email protected]
BREAKING
-
make conversions from apollo-parser types fallible - goto-bus-stop, pull/371
The
parser-impl
feature flag contains conversion code from apollo-parser AST node types
to apollo-smith types. With this change, those conversions now use theTryFrom
trait
instead of theFrom
trait, and return errors instead of panicking.You now have to use the
try_from()
andtry_into()
methods instead offrom()
and
into()
.
[email protected]
BREAKING
-
make conversions from GraphQL Values to Rust types fallible - goto-bus-stop, pull/371 fixing issue/358
In the past you could do:
let graphql_value: IntValue = get_a_value(); let x: i32 = graphql_value.into();
But this
.into()
implementation could panic if the number was out of range.
Now, this conversion is implemented with theTryFrom
trait, so you handle out-of-range errors however you want:let graphql_value: IntValue = get_a_value(); let x: i32 = graphql_value.try_into()?;
-
Move
with_recursion_limit
constructor to a builder method - goto-bus-stop, pull/347If you were using the
Parser::with_recursion_limit
constructor, you now need to useParser::new().recursion_limit()
instead.
Features
-
add API to limit number of tokens to parse - goto-bus-stop, pull/347
When dealing with untrusted queries, malicious users can submit very large queries to attempt to cause
denial-of-service by using lots of memory. To accompany the existingrecursion_limit
API preventing
stack overflows, you can now usetoken_limit
to abort parsing when a large number of tokens is reached.You can use the new
err.is_limit()
API to check if a parse failed because a hard limit was reached.let source = format!("query {{ {fields} }}", fields = "a ".repeat(20_000)); let parser = Parser::new(source) .recursion_limit(10) // You may need an even higher limit if your application actually sends very large queries! .token_limit(10_000); let (ast, errors) = parser.parse(); if errors.iter().any(|err| err.is_limit()) { // there was a limiting error }
Maintenance
- Use
eat()
in a loop instead of recursing inbump()
- goto-bus-stop, pull/361
[email protected]
BREAKING
-
[email protected] - goto-bus-stop, pull/371, pull/376
This updates the version of
apollo-parser
required by theTryFrom
implementations in this crate.
[email protected]
Features
-
add parser recursion limit API - SimonSapin, pull/353, issue/296
Calling
ApolloCompiler::with_recursion_limit
instead ofApolloCompiler::new
makes the compiler configure the corresponding parser limit.
This limit protects against stack overflow and is enabled either way.
Configuring it may be useful for example if you’re also configuring the stack size. -
expose the repeatable attribute on
DirectiveDefinition
- allancalix, pull/367There was previously no way to access the
repeatable
field on theDirectiveDefinition
type.
This field is required for validation rules. -
add type extensions - SimonSapin, pull/369
apollo-compiler now partially supports GraphQL
extend
types. Theis_subtype
query takes
extensions into account.Some other parts of the compiler, like validation, do not yet support extensions.
Fixes
-
fix
@include
allowed directive locations - allancalix, pull/366The locations for the
@include
directive wrongly specifiedFragmentDefinition
instead ofFragmentSpread
.
It now matches the spec.
Maintenance
- avoid double lookup in
SchemaDefinition::{query,mutation,subscription}
- SimonSapin, pull/364
[email protected]
0.3.2 - 2022-11-15
Fixes
-
lexing escaped and unicode characters in block strings - lrlna, pull/357 fixing issue/341, issue/342, issue/343
Fixes lexing the following string values:
"""unicode in block string 🤷"""
input Filter {
title: String
}
"""
\""" a/b \"""
"""
input Filter {
title: String
}
type Query {
format: String = "Y-m-d\\TH:i:sP"
}
[email protected]
BREAKING
-
update [email protected] - lrlna, pull/340, pull/348
This change was first released in the [email protected] patch release.
It should have been a breaking change, as the update to the new version
requires users to also update apollo-parser to 0.3.0 at the same time.This version is identical to 0.1.5 except for the version number.
apollo-smith versions 0.1.4 and 0.1.5 have been yanked.
[email protected]
0.1.5 - 2022-11-04
Maintenance
-
update [email protected] - lrlna, pull/348
-
update [email protected] - lrlna, pull/349