Skip to content

Latest commit

 

History

History
439 lines (307 loc) · 9.59 KB

CHANGELOG.md

File metadata and controls

439 lines (307 loc) · 9.59 KB

Changelog

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

Changed

  • use async-graphql 7

Fixed

  • fix clippy errors in generated codes

0.8.1 - 2023-11-06

Changed

  • remove dynamic_graphql::Upload struct and use async_graphql::Upload instead

0.8.0 - 2023-10-17

Changed

  • upgrade dependencies:
    • upgrade async-graphql to 6, syn to 2

Breaking Changes

  • change #[graphql(impl(Node))] to #[graphql(implements(Node))]

0.7.3 - 2023-03-28

Added

  • 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,
    }
}

Doc

  • add docs for Interface macro

0.7.2 - 2023-03-20

Added

  • add Registry::set_subscription method

Doc

  • add docs for SimpleObject macro
  • add docs for ResolvedObject and ResolvedObjectFields macro

0.7.1 - 2023-03-04

Internal

  • add Registry::apply_into_schema_builder method

0.7.0 - 2023-02-21

Added

  • 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

Fixed

  • fix silent integer overflow cast in FromValue trait. Now it returns error if value is out of range.

Internal

  • move internal types to internal module
  • simplify GetOutputTypeRef/GetInputTypeRef signatures
  • change signature of FromValue trait. Now it returns InputValueResult<Self>

0.6.1 - 2023-02-08

Added

  • Support generics in Union types

0.6.0 - 2023-02-08

Added

  • 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()
    }
}

Internal

  • remove MARK from Interface trait
  • use function instead constant for type names
  • rename GraphqlType to TypeName
  • rename InputType to InputTypeName
  • rename OutputType to OutputTypeName

0.5.4 - 2023-01-30

  • remove .parent() from expand object
  • improve lifetimes for ExpandObjectFields

0.5.3 - 2023-01-30

Internal

  • Improve Register, GraphqlType, OutputType for refs

0.5.2 - 2023-01-30

Internal

  • add Resolve trait to unify ResolveOwned and ResolveRef

0.5.1 - 2023-01-29

Fixed

  • dependency dynamic-graphql-derive version

0.5.0 - 2023-01-29

Added

  • 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>
}

Internal

  • Remove the InterfaceTarget trait

0.4.0 - 2023-01-28

Added

  • 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

Changed

  • force 'static lifetime for #[derive(App)] attribute
// old
#[derive(App)]
struct ExampleApp<'a>(ExampleQuery<'a>);
// new
#[derive(App)]
struct ExampleApp(ExampleQuery<'static>);

Breaking Changes

  • 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 })
    }
}

Internal

  • every GraphQLType now should implement Register trait
  • remove InterfaceRoot
  • add Instance struct, RegisterInstance trait
  • remove constraint Sized from T in Register<T>
  • significant changes in InterfaceMark trait

0.3.0 - 2023-01-25

Added

  • support Upload type

Fixed

  • fix remote in enum to accept path with :: separator

Breaking Change

  • remote in enum now defined as graphql(remote(path::to::Other)) instead of graphql(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

Changed

  • SimpleObject, ResolvedObject: change graphql(mark_as=), graphql(mark_with=), graphql(implement=) to graphql(mark()) and graphql(impl())
  • change async-graphql dependency to `5.0.5'

Breaking Change

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

Added

  • support for MaybeUndefined input type

Fixed

  • fix error when argument or optional input field is not provided
  • fix error when ResolvedObjectFields and ExpandedObjectFields are used on impl path (e.g. impl other::MyType)

Internal

  • remove GraphqlDoc trait
  • change FromValue argument to Result<dynamic::ValueAccessor>
  • add Output associated type to GetOutputTypeRef and GetInputTypeRef