I'm using async-graphql
and I'm trying to use this struct as SimpleObject
:
use async_graphql::{CSimpleObject};
#[derive(SimpleObject)]
struct Player {
id: String,
created_at: time::OffsetDateTime,
email: String,
}
but I'm getting this error:
error[E0277]: the trait bound `time::OffsetDateTime: OutputType` is not satisfied
|
50 | #[derive(SimpleObject)]
| ^^^^^^^^^^^^ the trait `OutputType` is not implemented for `time::OffsetDateTime`
|
= help: the following other types implement trait `OutputType`:
&'a [T]
&'impl0 T
Arc<T>
Arc<[T]>
BTreeMap<K, V>
BTreeSet<T>
Cow<'a, T>
Edge<Cursor, Node, EdgeFields, Name>
and 56 others
= note: required because of the requirements on the impl of `OutputType` for `&time::OffsetDateTime`
= note: this error originates in the derive macro `SimpleObject` (in Nightly builds, run with -Z macro-backtrace for more info)
What can I do to fix this?
I tried to search but I cannot understand what to do.
First, the problem: derivation is generally recursive, so all the members of a structure have to implement the trait being derived before the structure itself can.
Generally (de)serialization libraries will implement the trait on standard library types, but they can't feasibly do so for every crate out there (not to mention they would have to depend on all of them in the first place).
So the possible solutions are: