Macro juniper::graphql_input_object [] [src]

macro_rules! graphql_input_object {
    ( @maybe_apply, None, $func:ident, $val:expr ) => { ... };
    ( @maybe_apply, $arg:tt, $func:ident, $val:expr ) => { ... };
    ( @apply_description, , $val:expr ) => { ... };
    ( @apply_description, $descr:tt , $val:expr ) => { ... };
    (
        @generate_from_input_value,
        $name:tt, $var:tt,
        ( $($field_name:ident : $field_type:ty $(as $descr:tt)* $(,)* ),* )
    ) => { ... };
    (
        @generate_struct_fields,
        ( $($meta:tt)* ), $name:tt,
        ( $($field_name:ident : $field_type:ty $(as $descr:tt)* $(,)* ),* )
    ) => { ... };
    (
        @generate_meta_fields,
        $reg:tt,
        ( $($field_name:ident : $field_type:ty $(as $descr:tt)* $(,)* ),* )
    ) => { ... };
    (
        @parse,
        ( $_ignore1:tt, $_ignore2:tt, $_ignore3:tt, $_ignore4:tt, $descr:tt ),
        $(#[$meta:meta])* struct $name:ident { $($fields:tt)* } $($rest:tt)*
    ) => { ... };
    (
        @parse,
        ( $_ignore1:tt, $_ignore2:tt, $_ignore3:tt, $_ignore4:tt, $descr:tt ),
        $(#[$meta:meta])* struct $name:ident as $outname:tt { $($fields:tt)* } $($rest:tt)*
    ) => { ... };
    (
        @parse,
        ( $meta:tt, $name:tt, $outname:tt, $fields:tt, $_ignore:tt ),
        description: $descr:tt $($rest:tt)*
    ) => { ... };
    (
        @parse,
        ( $meta:tt, $name:tt, $outname:tt, $fields:tt, $descr:tt ),
    ) => { ... };
    ( $(#[$meta:meta])* struct $($items:tt)* ) => { ... };
    ( description: $($items:tt)* ) => { ... };
}

Create an input object

Input objects are used as data carriers for complex input values to fields and mutations. Unlike the other helper macros, graphql_input_object! actually creates the struct you define. It does not add anything to the struct definition itself - what you type is what will be generated:


graphql_input_object!(
    description: "Coordinates for the user"

    struct Coordinates {
        longitude: f64 as "The X coordinate, from -180 to +180",
        latitude: f64 as "The Y coordinate, from -90 to +90",
    }
);

This macro creates the struct as specified and implements FromInputValue to automatically parse values provided from variables and arguments.

If you want to expose the struct under a different name than the Rust type, you can write struct Coordinates as "MyCoordinates" { ....