Async Graphql Json InputObject Type

Hi,

I'm trying to use Async Graphql, I want to use sqlx json type in model. In normal api operations the code is running. But when I want to use the async graphql InputObject macro, I get an error. The codes I used are as follows, I couldn't find a solution for the problem.

#[derive(Serialize, Deserialize, Debug, Clone, sqlx::Type)]
#[sqlx(transparent)]
pub struct Meta(Map<String, Value>);

scalar!(Meta);

#[derive(Debug, Serialize, Deserialize, Clone, FromRow, SimpleObject)]
pub struct User {
    #[serde(skip_serializing)]
    #[graphql(skip)]
    pub id: Uuid,
    pub name: String,
    pub email: String,
    #[serde(skip_serializing)]
    #[graphql(skip)]
    pub password: String,
    #[serde(skip_serializing)]
    #[graphql(skip)]
    pub meta: Json<Meta>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}

No problem so far. But the code below gives an error.

#[derive(Debug, Deserialize, Validate, InputObject)]
pub struct RegisterInput {
    #[validate(length(min = 4, max = 10))]
    pub name: String,
    #[validate(email)]
    pub email: String,
    #[validate(length(min = 6))]
    pub password: String,
    pub meta: Json<Meta>,
}

InputObject error.

error[E0277]: the trait bound `sqlx::types::Json<Meta>: InputType` is not satisfied
  --> src/dto.rs:13:40
   |
13 | #[derive(Debug, Deserialize, Validate, InputObject)]
   |                                        ^^^^^^^^^^^ the trait `InputType` is not implemented for `sqlx::types::Json<Meta>`
   |
   = help: the following other types implement trait `InputType`:
             Arc<T>
             Arc<[T]>
             Arc<str>
             BTreeMap<K, V>
             BTreeSet<T>
             Box<T>
             Box<[T]>
             Box<str>
           and 49 others
   = note: this error originates in the derive macro `InputObject` (in Nightly builds, run with -Z macro-backtrace for more info)

Can you help on the subject?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.