Skip to content

Async support for Interfaces is not implemented on master #605

Closed
@Ekzer

Description

@Ekzer

Hi there!
I am getting troubles to make this simple piece of code working :


#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, juniper::GraphQLObject)]
pub struct Unit {
    id: String,
    duration: i32,
    productionNationalityCode: Vec<String>,
    format: Format
}

#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, juniper::GraphQLObject)]
pub struct Format {
    quality: Vec<String>,
    dst: bool,
    audio: Vec<String>,
    drmType: Vec<String>,
    distTechnology: Vec<String>,
    functionalType: Vec<String>,
    version: Vec<String>,
    comMode: Vec<String>,
    qad: bool
}

trait ContentInterface {
    fn id(&self) -> &str;

    fn as_unit(&self) -> Option<&Unit> { None }
}

impl ContentInterface for Unit {
    fn id(&self) -> &str {
        self.id.as_str()
    }

    fn as_unit(&self) -> Option<&Unit> { Some(self) }
}

juniper::graphql_interface!(<'a> &'a ContentInterface: () as "ContentInterface" where Scalar = <S> |&self| {
    field id() -> &str { self.id() }

    instance_resolvers: |_| {
        // The left hand side indicates the concrete type T, the right hand
        // side should be an expression returning Option<T>
        &Unit => self.as_unit()
    }
});

I a getting this error :

40 | / juniper::graphql_interface!(<'a> &'a ContentInterface: () as "ContentInterface" where Scalar = <S> |&self| {
41 | |     field id() -> &str { self.id() }
42 | |
43 | |     instance_resolvers: |_| {
...  |
47 | |     }
48 | | });
   | |___^ cannot infer type for type parameter `S`

Thank you for your help in advance !
Best regards

Metadata

Metadata

Assignees

Labels

area::asyncRelated to async/.await functionalityblocker

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions