Releases: apollographql/apollo-rs
[email protected]
Features
-
add
SyntaxTree::token_limit
- SimonSapin, pull/525
This enables finding out how many tokens were present in a succesful parse,
which can be useful to choose where to set the limit. -
add
Definition::kind() -> &str
andDefinition::is_executable_definition()
- goto-bus-stop, pull/535
These are new methods on theDefinition
AST node.kind()
returns the kind
of definition (eg. "ScalarTypeExtension") andis_executable_definition()
returns true for operation definitions and fragment definitions.
Fixes
- handle escape sequences when reading string contents - goto-bus-stop, pull/541
TheString::from(StringValue)
implementation now turns escape sequences like
\n
and\u2764
into their literal characters.
[email protected]
0.5.1 - 2023-04-13
Fixes
- remove recursion in field parsing - goto-bus-stop, pull/519
Theselection::selection_set
parser already supports parsing multiple fields.
This removes recursion from field parsing, reducing the risk of stack
overflow on queries with many fields.
[email protected]
0.5.1 - 2023-04-13
Featues
- add
Clone
impl to encoder types - zackangelo, pull/515
Consistently deriveClone
on all encoder types.
[email protected]
0.8.0 - 2023-04-13
BREAKING
There is now an API to set parser's token limits via apollo-compiler
. To
accommodate an additional limit, we changed the API to set several limits
simultaneously.
let op = r#"
query {
a {
a {
a {
a
}
}
}
}
"#;
let mut compiler = ApolloCompiler::new().token_limit(22).recursion_limit(10);
compiler.add_executable(op, "op.graphql");
let errors = compiler.db.syntax_errors();
assert_eq!(errors.len(), 1)
Features
- validate fragment definitions are used, by gocamille in pull/483
- validate fragment type condition exists in the type system and are declared on composite types, by gocamille in pull/483
- validate fragment definitions do not contain cycles, by goto-bus-stop in pull/518
Fixes
- fix duplicate directive location info, by goto-bus-stop in pull/516
- use
LimitExceeded
diagnostic for limit related errors, by lrlna in pull/520
[email protected]
[email protected]
0.7.0 - 2023-03-27
Important: X breaking changes below, indicated by BREAKING
This release encompasses quite a few validation rules the compiler was missing.
Here, we primarily focused on field and directive validation, as well as supporting
multi-file diagnostics.
BREAKING
-
find_operation
query now mimics spec's
getOperation
functionality and returns the anonymous operation ifNone
is specified for
operation name; by lrlna in pull/447 -
Extensions are applied implicitly in HIR by SimonSapin in pull/481,
pull/482, and pull/484Adding a GraphQL type extension is similar to modifying a type.
This release makes a number of breaking changes to API signatures and behavior
so these modifications are accounted for implicitly.
For example,interface.field(name)
may now return a field
from anextend interface
extension or from the originalinterface
definition.
We expect that most callers don’t need to tell the difference.
For callers that do, methods with aself_
prefix are added (or renamed)
for accessing components of a definition itself as opposed to added by an extension.Renamed methods:
-SchemaDefinition::root_operation_type_definition
→self_root_operations
-ObjectTypeDefinition::fields_definition
→self_fields
-InterfaceTypeDefinition::fields_definition
→self_fields
-InputObjectTypeDefinition::input_fields_definition
→self_fields
-ObjectTypeDefinition::implements_interfaces
→self_implements_interfaces
-InterfaceTypeDefinition::implements_interfaces
→self_implements_interfaces
-UnionTypeDefinition::union_members
→self_members
-EnumTypeDefinition::enum_values_definition
→self_values
-TypeDefiniton::directives
→self_directives
-SchemaDefiniton::directives
→self_directives
-EnumTypeDefiniton::directives
→self_directives
-UnionTypeDefiniton::directives
→self_directives
-ObjectTypeDefiniton::directives
→self_directives
-ScalarTypeDefiniton::directives
→self_directives
-InterfaceTypeDefiniton::directives
→self_directives
-InputObjectTypeDefiniton::directives
→self_directives
Method names freed by the above are now redefined with new behaviour and
signature, and include extensions:
-ObjectTypeDefinition::implements_interfaces() -> impl Iterator
-InterfaceTypeDefinition::implements_interfaces() -> impl Iterator
-TypeDefiniton::directives() -> impl Iterator
-SchemaDefiniton::directives() -> impl Iterator
-EnumTypeDefiniton::directives() -> impl Iterator
-UnionTypeDefiniton::directives() -> impl Iterator
-ObjectTypeDefiniton::directives() -> impl Iterator
-ScalarTypeDefiniton::directives() -> impl Iterator
-InterfaceTypeDefiniton::directives() -> impl Iterator
-InputObjectTypeDefiniton::directives() -> impl Iterator
Methods whose behaviour and signature changed, where each method now returns the
name of an object type instead of its definition:
-SchemaDefinition::query() -> Option<&str>
-SchemaDefinition::mutation() -> Option<&str>
-SchemaDefinition::subscription() -> Option<&str>
Methods whose behaviour changed to consider extensions, and no signature has changed
-TypeDefinition::field(name) -> Option
-ObjectTypeDefinition::field(name) -> Option
-InterfaceTypeDefinition::field(name) -> Option
New methods which take extensions into consideration:
-SchemaDefinition::root_operations() -> impl Iterator
-ObjectTypeDefinition::fields() -> impl Iterator
-ObjectTypeDefinition::implements_interface(name) -> bool
-InterfaceTypeDefinition::fields() -> impl Iterator
-InterfaceTypeDefinition::implements_interface(name) -> bool
-InputObjectTypeDefinition::self_fields() -> &[_]
-InputObjectTypeDefinition::fields() -> impl Iterator
-InputObjectTypeDefinition::field(name) -> Option
-UnionTypeDefinition::members() -> impl Iterator
-UnionTypeDefinition::has_member(name) -> bool
-EnumTypeDefinition::values() -> impl Iterator
-EnumTypeDefinition::value(name) -> Option
New methods for every type which have a
directives
method:
-directive_by_name(name) -> Option
-directives_by_name(name) -> impl Iterator
Features
- support mutli-file diagnostics by goto-bus-stop in pull/414
- validate directive locations by lrlna in pull/417
- validate undefined directives by lrlna in pull/417
- validate non-repeatable directives in a given location by goto-bus-stop in pull/488
- validate conflicting fields in a selection set (spec: fields can merge) by goto-bus-stop in pull/470
- validate introspection fields in subscriptions by gocamille in [pull/438]
- validate required arguments by goto-bus-stop in pull/452
- validate unique variables by lrlna in pull/455
- validate variables are of input type by lrlna in pull/455
- validate root operation type is of Object Type by lrlna in pull/419
- validate nested fields in selection sets by erikwrede in pull/441
- validate extension existance and kind by goto-bus-stop in pull/458
- validate leaf field selection by [yanns] in pull/465
- introduce
op.is_introspection
helper method by jregistr in pull/421 - built-in graphql types, including introspection types, are now part of the
compiler context by lrlna in pull/489
Fixes
- fix variables in directive arguments being reported as unused goto-bus-stop in pull/487
op.operation_ty()
does not deref lrlna in pull/434
Maintenance
- tests for operation field type resolution v.s. type extensions by SimonSapin in pull/492
- using [salsa::invoke] macro to annotate trait function location by lrlna in pull/491
- use
Display
forhir::OperationType
andhir::DirectiveLocation
by goto-bus-stop in pull/435 - rework and simplify validation database by lrlna in pull/436
- reset
FileId
between directory tests by goto-bus-stop in pull/437 - remove unncessary into_iter() calls by goto-bus-stop in pull/472
- check test numbers are unique in test output files by goto-bus-stop in pull/471
[email protected]
Features
- new
ast::Definition
methods - goto-bus-stop, pull/456
When working withDefinition
nodes, you can use the.name()
method to get the name of a definition, regardless of its kind. Forschema
definitions, it returnsNone
.
You can use.is_extension_definition()
to check if a definition node is an extension.
Fixes
-
fix token order around type names - goto-bus-stop, issue/362, pull/443
type Query { field: Int # comment }
Previously, the whitespace and comment around the
Int
type name would end up before the type name in the parse tree. This would mess up the location information for theInt
type name. Now this is fixed. -
fix spans after parsing unexpected tokens - goto-bus-stop, issue/325, pull/446
Location information for all nodes after an unexpected token was incorrect. It's better now, though still imperfect: lexing errors still have this problem.
-
fix ignored token positioning in the AST - goto-bus-stop, pull/445
This makes spans for all nodes more specific, not including ignored tokens after the node. When ignored tokens are consumed, they are first stored separately, and then added to the AST just before the next node is started. This way ignored tokens are always inside the outermost possible node, and therefore all individual nodes will have spans that only contain that node and not more.
The most obvious effect of this is that diagnostics now point to the exact thing they are about, instead of a bunch of whitespace :)
[email protected]
BREAKING
-
[email protected] - goto-bus-stop, pull/459
This updates the version of
apollo-parser
required by theTryFrom
implementations in this crate.
Features
[email protected]
0.6.0 - 2023-01-18
This release has a few breaking changes as we try to standardise APIs across the
compiler. We appreciate your patience with these changes. If you run into trouble, please open an issue.
BREAKING
- Rename
compiler.create_*
methods tocompiler.add_*
, SimonSapin in 412 - Rename
schema
totype_system
forcompiler.add_
andcompiler.update_
methods, SimonSapin in 413 - Unify
ty
,type_def
andkind
namings in HIR, lrlna in 415- in
Type
struct impl:ty()
-->type_def()
- in
TypeDefinition
struct impl:ty()
-->kind()
- in
FragmentDefinition
struct impl:ty()
-->type_def()
- in
RootOperationTypeDefinition
struct:operation_type
field -->
operation_ty
- in
Features
FileId
s are unique per process, SimonSapin in 405- Type alias
compiler.snapshot()
return type toSnapshot
, SimonSapin in
410 - Introduce a type system high-level intermediate representation (HIR) as input
to the compiler, SimonSapin in 407
Fixes
Maintenance
Documentation
- Document
apollo-rs
runs on stable, SimonSapin in 402
[email protected]
0.5.0 - 2023-01-04
Highlights
Multi-file support
You can now build a compiler from multiple sources. This is especially useful
when various parts of a GraphQL document are coming in at different times and
need to be analysed as a single context. Or, alternatively, you are looking to
lint or validate multiple GraphQL files part of the same context in a given directory or workspace.
The are three different kinds of sources:
document
: for when a source is composed of executable and type system
definitions, or you're uncertain of definitions typesschema
: for sources with type system definitions or extensionsexecutable
: for sources with executable definitions/GraphQL queries
You can add a source with create_
and update it with update_
, for example
create_document
and update_document
. Here is an example:
let schema = r#"
type Query {
dog: Dog
}
type Dog {
name: String!
}
"#;
let query = r#"
query getDogName {
dog {
name
}
}
# duplicate name, should show up in diagnostics
query getDogName {
dog {
owner {
name
}
}
}
"#;
let updated_schema = r#"
type Query {
dog: Dog
}
type Dog {
name: String!
owner: Human
}
type Human {
name: String!
}
"#;
let mut compiler = ApolloCompiler::new();
let schema_id = compiler.create_schema(schema, "schema.graphl");
let executable_id = compiler.create_executable(query, "query.graphql");
compiler.update_schema(updated_schema, schema_id);
For more elaborate examples, please refer to multi_source_validation
and
file_watcher
examples in the examples
dir.
We look forward to your feedback on this feature, should you be using it.
Completed in pull/368 in collaboration with goto-bus-stop, SimonSapin and
lrlna.
BREAKING
- Remove UUID helpers and related UUID APIs from database by SimonSapin in
pull/391 - Merge
DocumentDatabase
trait intoHIRDatabase
by SimonSapin in
pull/394 - Replace
hir::Definition
enum withhir::TypeSystemDefinitions
struct by
SimonSapin in pull/395 db.type_system_definitions
returns aTypeSystemDefinitions
by SimonSapin
in pull/395- Remove
db.db_definitions
,find_definition_by_name
and
find_type_system_definition_by_name
by SimonSapin in pull/395 - Remove queries returning type extensions, instead type definitions in the HIR
contain extension information by SimonSapin in pull/387
Features
db.fragments
,db.object_types
,db.scalars
,db.enums
,db.unions
,
db.interfaces
,db.input_objects
, anddb.directive_definitions
return
name-indexed maps by SimonSapin in pull/387