All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased - ReleaseDate
0.9.0 - 2024-05-31
- use async-graphql 7
- fix clippy errors in generated codes
0.8.1 - 2023-11-06
- remove
dynamic_graphql::Upload
struct and useasync_graphql::Upload
instead
0.8.0 - 2023-10-17
- upgrade dependencies:
- upgrade
async-graphql
to6
,syn
to2
- upgrade
- change
#[graphql(impl(Node))]
to#[graphql(implements(Node))]
0.7.3 - 2023-03-28
- Add
#[graphql(validator(validate_fn))]
attribute to validate scalar value
#[derive(Scalar)]
#[graphql(validator(validate_foo))]
struct Foo(String);
fn validate_foo(value: &Value) -> bool {
match value {
Value::String(s) => s.len() <= 5,
_ => false,
}
}
- add docs for
Interface
macro
0.7.2 - 2023-03-20
- add
Registry::set_subscription
method
- add docs for
SimpleObject
macro - add docs for
ResolvedObject
andResolvedObjectFields
macro
0.7.1 - 2023-03-04
- add
Registry::apply_into_schema_builder
method
0.7.0 - 2023-02-21
- add Scalar support
#[derive(Scalar)]
struct MyScalar {
value: String
}
impl ScalarValue for MyScalar {
fn from_value(value: dynamic_graphql::Value) -> dynamic_graphql::Result<Self> {
match value {
dynamic_graphql::Value::String(value) => Ok(MyScalar { value }),
_ => Err(dynamic_graphql::Error::new("Invalid value")),
}
}
fn to_value(&self) -> dynamic_graphql::Value {
dynamic_graphql::Value::String(self.value.clone())
}
}
- support
Result
as input type
- fix silent integer overflow cast in
FromValue
trait. Now it returns error if value is out of range.
- move internal types to
internal
module - simplify
GetOutputTypeRef
/GetInputTypeRef
signatures - change signature of
FromValue
trait. Now it returnsInputValueResult<Self>
0.6.1 - 2023-02-08
- Support generics in
Union
types
0.6.0 - 2023-02-08
- add
#[graphql(get_type_name)
attribute to override type name
use std::borrow::Cow;
#[derive(SimpleObject)]
#[graphql(get_type_name)]
struct Foo {
value: String
}
impl TypeName for Foo {
fn get_type_name() -> Cow<'static, str> {
"Bar".into()
}
}
- remove
MARK
fromInterface
trait - use function instead constant for type names
- rename
GraphqlType
toTypeName
- rename
InputType
toInputTypeName
- rename
OutputType
toOutputTypeName
0.5.4 - 2023-01-30
- remove
.parent()
from expand object - improve lifetimes for
ExpandObjectFields
0.5.3 - 2023-01-30
- Improve
Register
,GraphqlType
,OutputType
for refs
0.5.2 - 2023-01-30
- add
Resolve
trait to unifyResolveOwned
andResolveRef
0.5.1 - 2023-01-29
- dependency
dynamic-graphql-derive
version
0.5.0 - 2023-01-29
- Add
#[graphql(register())]
attribute to register types manually
#[derive(SimpleObject)]
struct Foo { value: String }
#[derive(SimpleObject)]
#[graphql(register(Foo))] // also register `Foo` type when Example is registered
struct Example { value: String }
- Add
#[graphql(auto_register())]
attribute to register types automatically for each instance of interface
/// call `registry.register::<Foo<T>>()` for each instance of `Node` (T)
#[Interface]
#[graphql(auto_register(Foo))]
trait Node {
fn id(&self) -> String;
}
- Add schema
data
to share data between schema definitions and execution time
// schema definition time
fn register(mut registry: Registry) -> Registry {
let my_data: &mut MyStruct = registry.data.get_mut_or_default();
}
// execution time
fn some_fn(ctx: &Context<'_>){
let my_data = ctx.get_schema_data().get::<MyStruct>(); // Option<&MyStruct>
}
- Remove the
InterfaceTarget
trait
0.4.0 - 2023-01-28
- Automatic register used types.
#[derive(SimpleObject)]
struct Example { value: String }
#[derive(SimpleObject)]
struct Query { example: Example }
#[derive(App)]
struct App (Query); // no need to register Example manually
- force
'static
lifetime for#[derive(App)]
attribute
// old
#[derive(App)]
struct ExampleApp<'a>(ExampleQuery<'a>);
// new
#[derive(App)]
struct ExampleApp(ExampleQuery<'static>);
- remove support for mark object as interface with string
#[graphql(mark("Node"))]
- The way of defining the interface is changed. No need to define a new name (e.g.,
NodeInterface
) for the interface and use it in#[graphql(mark(NodeInterface))]
and#[graphql(impl(NodeInterface))]
attributes. Now you can use#[graphql(mark(Node))]
and#[graphql(impl(Node))]
attributes.
// old
#[Interface(NodeInterface)]
trait Node {
fn id(&self) -> String;
}
#[derive(SimpleObject)]
#[graphql(mark(NodeInterface))]
struct Foo { id: String }
#[derive(SimpleObject)]
#[graphql(impl(NodeInterface))]
struct Bar;
impl Node for Bar {
fn id(&self) -> String {
"bar".to_string()
}
}
#[derive(ResolvedObject)]
struct Query;
#[ResolvedObjectFields]
impl Query {
async fn node(&self, id: String) -> NodeInterface {
NodeInterface::new_owned(Foo { id })
}
}
// new
#[Interface]
trait Node {
fn id(&self) -> String;
}
#[derive(SimpleObject)]
#[graphql(mark(Node))]
struct Foo {
id: String,
}
#[derive(SimpleObject)]
#[graphql(impl(Node))]
struct Bar;
impl Node for Bar {
fn id(&self) -> String {
"bar".to_string()
}
}
#[derive(ResolvedObject)]
struct Query;
#[ResolvedObjectFields]
impl Query {
async fn node(&self, id: String) -> Instance<dyn Node> {
Instance::new_owned(Foo { id })
}
}
- every
GraphQLType
now should implementRegister
trait - remove
InterfaceRoot
- add
Instance
struct,RegisterInstance
trait - remove constraint
Sized
fromT
inRegister<T>
- significant changes in
InterfaceMark
trait
0.3.0 - 2023-01-25
- support
Upload
type
- fix
remote
in enum to accept path with::
separator
remote
in enum now defined asgraphql(remote(path::to::Other))
instead ofgraphql(remote = "path::to::Other")
// old
#[derive(Enum)]
#[graphql(remote = "path::to::Other")]
enum MyEnum {}
// new
#[derive(Enum)]
#[graphql(remote(path::to::Other))]
enum MyEnum {}
0.2.0 - 2023-01-25
SimpleObject
,ResolvedObject
: changegraphql(mark_as=)
,graphql(mark_with=)
,graphql(implement=)
tographql(mark())
andgraphql(impl())
- change
async-graphql
dependency to `5.0.5'
before this release SimpleObject
, ResolvedObject
can implement interfaces this way:
#[derive(SimpleObject)]
#[graphql(mark_as = "Node")]
struct MyType {}
#[derive(SimpleObject)]
#[graphql(mark_with = "NodeInterface")]
struct OtherType {}
#[derive(SimpleObject)]
#[graphql(implement = "NodeInterface")]
struct AnotherType {}
after this release SimpleObject
, ResolvedObject
can implement interfaces this way:
#[derive(SimpleObject)]
#[graphql(mark("Node"))]
struct MyType {}
#[derive(SimpleObject)]
#[graphql(mark(NodeInterface))]
struct OtherType {}
#[derive(SimpleObject)]
#[graphql(impl(NodeInterface))]
struct AnotherType {}
0.1.1 - 2023-01-24
- support for
MaybeUndefined
input type
- fix error when argument or optional input field is not provided
- fix error when
ResolvedObjectFields
andExpandedObjectFields
are used on impl path (e.g.impl other::MyType
)
- remove
GraphqlDoc
trait - change
FromValue
argument toResult<dynamic::ValueAccessor>
- add
Output
associated type toGetOutputTypeRef
andGetInputTypeRef