Skip to content

#[juniper::object] interfaces attribute not documented #658

Description

@jacobh

Hi,

this afternoon I've been porting some graphql types to using the attribute macro syntax. I was stuck trying to get my interfaces working correctly.

I think I've figured it out, with interfaces now being an attribute of the macro, but I couldn't see any mention of that syntax anywhere in the docs, and had to dig into the source.

Other than this I'm very much liking the attribute macro syntax! reads much more nicely, and rustfmt works correctly.

Old:

graphql_object!(DynamicQueueContext: Context as "DynamicQueue" |&self| {
    interfaces: [Box<dyn QueueContext>]

    // Queue interface fields
    field id() -> Uuid {
        ContextItem::id(self)
    }
    field name() -> String {
        self.name()
    }
    ...
}

New:

#[juniper::object(
    name = "DynamicQueue"
    Context = Context
    interfaces = [Box<dyn QueueContext>]
)]
impl DynamicQueueContext {
    // Queue interface fields
    fn id(&self) -> Uuid {
        ContextItem::id(self)
    }
    fn name(&self) -> String {
        self.name()
    }
    ...
}

Activity

  1. self-assigned this
    on Jun 30, 2020
  2. tyranron commented on Oct 6, 2020

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

Metadata

Metadata

Assignees

Labels

k::documentationRelated to project documentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions