-
Notifications
You must be signed in to change notification settings - Fork 434
Closed
Labels
k::documentationRelated to project documentationRelated to project documentation
Description
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()
}
...
}
Metadata
Metadata
Assignees
Labels
k::documentationRelated to project documentationRelated to project documentation