Derive Macro async_graphql::MergedObject

source ·
#[derive(MergedObject)]
{
    // Attributes available to this derive:
    #[graphql]
}
Expand description

Define a merged object with multiple object types.

See also the Book.

Macro attributes

AttributedescriptionTypeOptional
nameObject namestringY
name_typeIf true, the object name will be specified from async_graphql::TypeName traitboolY
cache_controlObject cache controlCacheControlY
extendsAdd fields to an entity that’s defined in another serviceboolY
visibleIf false, it will not be displayed in introspection. See also the Book.boolY
visibleCall the specified function. If the return value is false, it will not be displayed in introspection.stringY
serialResolve each field sequentially.boolY
inaccessibleIndicate that an object is not accessible from a supergraph when using Apollo FederationboolY
tagArbitrary string metadata that will be propagated to the supergraph when using Apollo Federation. This attribute is repeatablestringY

Examples

use async_graphql::*;

#[derive(SimpleObject)]
 struct Object1 {
    a: i32,
 }

#[derive(SimpleObject)]
struct Object2 {
    b: i32,
}

#[derive(SimpleObject)]
struct Object3 {
    c: i32,
}

#[derive(MergedObject)]
struct MyObj(Object1, Object2, Object3);

let obj = MyObj(Object1 { a: 10 }, Object2 { b: 20 }, Object3 { c: 30 });