#[derive(GraphQLInterface)]
{
// Attributes available to this derive:
#[graphql]
}
Expand description
#[derive(GraphQLInterface)]
macro for generating a GraphQL interface
implementation for traits and its implementers.
This macro is applicable only to structs and useful in case interface fields don’t have any arguments:
use juniper::{GraphQLInterface, GraphQLObject};
// NOTICE: By default a `CharacterValue` enum is generated by macro to represent values of this
// GraphQL interface.
#[derive(GraphQLInterface)]
#[graphql(for = Human)] // enumerating all implementers is mandatory
struct Character {
id: String,
}
#[derive(GraphQLObject)]
#[graphql(impl = CharacterValue)] // notice the enum type name, not trait name
struct Human {
id: String, // this field is used to resolve Character::id
home_planet: String,
}
For more info and possibilities see #[graphql_interface]
macro.