1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
use std::collections::HashMap;
use crate::Input;
use super::InputDefinition;
/// ### Directive Definition
///
/// Directives are used to modify the behavior of a resolver, types.
/// and provide additional information and metadata.
///
/// Directives can be applied on a field, type, enum, enum value, or input args.
///
/// They can also have arguments, which can also be optional by setting a default.
///
/// ```notrust
/// directive @lowercase on FieldDefinition
/// directive @deprecated(
/// reason: String = "No longer supported"
/// )
/// ```
#[derive(Debug, PartialEq, Clone)]
pub struct DirectiveDefinition {
pub ident: Box<str>,
pub input_definitions: HashMap<Box<str>, InputDefinition>,
}
/// ### AppliedDirective
/// A directive being applied or used on a field, type, enum, enum value, or input arg.
///
/// Named below for convenience.
/// ```notrust
/// @type_directive(arg: 123)
/// type Root {
/// this_is_a_field(arg: String): String @FieldDefinition(an_arg: 123)
/// }
/// ```
#[derive(Debug, PartialEq, Clone)]
pub struct AppliedDirective {
pub ident: Box<str>,
pub inputs: HashMap<Box<str>, Input>,
}