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