Hello All,
For some reason, i am not able to use the following struct/object type combo.
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct CmdbCiService {
pub sys_created_on: Option<NaiveDateTime>,
}
#[Object]
impl CmdbCiService {
async fn sys_created_on(&self) -> Option<DateTime<Utc>> {
Some(DateTime::<Utc>::from_utc(self.sys_created_on?, Utc))
}}
I receive the following error:
pub fn Object(args: TokenStream, input: TokenStream) -> TokenStream
the trait bound DateTime<Utc>: async_graphql::Type is not satisfied
required because of the requirements on the impl of async_graphql::Type for std::option::Option<DateTime<Utc>>
required by create_type_inforustcE0277
the trait bound DateTime<Utc>: OutputType is not satisfied
required because of the requirements on the impl of OutputType for std::option::Option<DateTime<Utc>>rustcE0277
lib.rs(1, 1): required by a bound in this
base.rs(60, 14): required by this bound in async_graphql::OutputType::resolve
Its crazy because I can copy paste this into my other project and it works fine!
Please let me know why this isnt working iof possible.
[dependencies]
serde_json = "1.0"
serde = {version = "1.0", features = ["derive"] }
dotenv = "0.15.0"
sqlx = { version = "0.4.2", features = [ "runtime-tokio-rustls","mssql","macros","chrono" ] }
chrono = { version = "0.4.19", features = ["serde"] }
anyhow = "1.0.37"
serde_derive = "1.0.123"
log = "0.4.0"
env_logger = "0.8.2"
async-graphql = "2.0"
async-graphql-actix-web = "2.0"
uuid = { version = "0.8.1", features = ["serde", "v4"] }
Windows 10
Is there a version mismatch? I see that Type is implemented for Datetime
You should add chrono feature for async-graphql.
You should add
chronofeature forasync-graphql.
Thanks! That worked. I wonder why I didn't need to add a feature in my past projects.
Much appreciated
In previous versions, I removed all features that were turned on by default.
Most helpful comment
You should add
chronofeature forasync-graphql.