BREAKING
-
Make everything know their own name - SimonSapin, pull/727 fixing issue/708.
In a few places (but not consistently) a
name
field
was omitted from some structs used as map values
on the basis that it would have been redundant with the map key.
This reverts that decision,
making it the user’s responsibility when mutating documents to keep names consistent.- Add a
pub name: Name
field toexecutable::Fragment
as well as
ScalarType
,ObjectType
,InterfaceType
,EnumType
,UnionType
, andInputObjectType
inschema
. - Add a
fn name(&self) -> &Name
method to theschema::ExtendedType
enum - Add a
pub name: Option<Name>
field toexecutable::Operation
- Remove
executable::OperationRef<'_>
(which was equivalent to(Option<&Name>, &Node<Operation>)
),
replacing its uses with&Node<Operation>
- Add a
-
Rename
Directives
andDiagnostics
toDirectiveList
andDiagnosticList
-
SimonSapin, pull/732 fixing issue/711.
The previous names were too similar toDirective
andDiagnostic
(singular). -
Rename
ComponentStr
toComponentName
- SimonSapin, pull/713
and itsnode: NodeStr
field toname: Name
. -
Assorted changed to GraphQL names - SimonSapin, pull/713 fixing issue/710.
- Check validity of
ast::Name
.
NodeStr
is a smart string type with infallible conversion from&str
.
ast::Name
used to be a type alias forNodeStr
,
leaving the possibility of creating one invalid in GraphQL syntax.
Validation and serialization would not check this.
Name
is now a wrapper type forNodeStr
.
Itsnew
constructor checks validity of the given string and returns aResult
.
A newname!
macro (see below) creates aName
with compile-time checking. OperationType::default_type_name
returns aName
instead of&str
Type::new_named("x")
is removed. UseType::Named(name!("x"))
instead.ComponentStr
is renamed toComponentName
.
It no longer has infallible conversions from&str
orString
.
Itsnode
field is renamed toname
;
the type of that field is changed fromNodeStr
toName
.NodeStr
no longer has ato_component
method, onlyName
does- Various function or method parameters changed from
impl Into<Name>
toName
,
since there is no longer an infallible conversion from&str
- Check validity of
Features
-
Add serialization support for everything - SimonSapin, pull/728.
Schema
,ExecutableDocument
, and all AST types
already supported serialization to GraphQL syntax
through theDisplay
trait and the.serialize()
method.
This is now also the case of all other Rust types
representing some element of a GraphQL document:schema::Directives
schema::ExtendedType
schema::ScalarType
schema::ObjectType
schema::InterfaceType
schema::EnumType
schema::UnionType
schema::InputObjectType
executable::Operation
executable::Fragment
executable::SelectionSet
executable::Selection
executable::Field
executable::InlineFragment
executable::FragmentSpread
executable::FieldSet
-
Assorted changed to GraphQL names - SimonSapin, pull/713 fixing issue/710.
See also the BREAKING section above.- Add a
name!("example")
macro,
to be imported withuse apollo_compiler::name;
.
It creates anast::Name
from a string literal, with a compile-time validity checking.
AName
created this way does not own allocated heap memory or a reference counter,
so cloning it is extremely cheap. - Add allocation-free
NodeStr::from_static
.
This mostly exists to support thename!
macro, but can also be used on its own:let s = apollo_compiler::NodeStr::from_static(&"example"); assert_eq!(s, "example");
- Add a
Fixes
- Fix crash in validation of self-referential fragments - goto-bus-stop, pull/733 fixing issue/716.
Now fragments that cyclically reference themselves inside a nested field also produce a
validation error, instead of causing a stack overflow crash.