Skip to content

Async support for Interfaces is not implemented on master #605

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

Activity

  1. LegNeato commented on Apr 6, 2020

    @LegNeato
    Member

    Are you using master? Interfaces have yet to be ported to async master and thus don't currently work on master.

  2. Ekzer commented on Apr 6, 2020

    @Ekzer
    Author

    Hi @LegNeato ,
    I am using the async one yes.
    juniper = {git = "https://github.com/graphql-rust/juniper", features=["async"]}

    So I have to go back on classic master if I understood well ?

  3. LegNeato commented on Apr 10, 2020

    @LegNeato
    Member

    Either you need to use the latest release on crates.io (which is sync but has interfaces and unions) or you need to wait until master has support for interfaces (happy to take a PR as well!).

    Also, you should be able to delete features=["async"] with latest master.

  4. LegNeato commented on Apr 10, 2020

    @LegNeato
    Member

    Related to #549

  5. changed the title [-]Trying to define an interface[/-] [+]Async support for Interfaces is not implemented on master[/+] on Apr 10, 2020
  6. Ekzer commented on Apr 10, 2020

    @Ekzer
    Author

    Thank you for your clear answer !
    I will give a try then to give async support for interface, good challenge for me as I'm relatively new to this language :)

  7. added a commit that references this issue on Apr 23, 2020
  8. added a commit that references this issue on Jun 5, 2020
  9. self-assigned this
    on Jun 30, 2020
  10. tyranron commented on Oct 6, 2020

    @tyranron
    Member

    Landed in #682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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