2021-11-11 07:22:40 +00:00
use std ::collections ::HashSet ;
2020-03-04 06:24:44 +00:00
use crate ::model ::__InputValue ;
2020-09-18 00:52:13 +00:00
use crate ::{ registry , Enum , Object } ;
2020-03-04 06:24:44 +00:00
2020-05-10 04:41:05 +00:00
/// A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.
2020-09-18 00:52:13 +00:00
#[ derive(Debug, Enum, Copy, Clone, Eq, PartialEq) ]
2020-10-14 09:08:57 +00:00
#[ graphql(internal, name = " __DirectiveLocation " ) ]
2020-03-04 06:24:44 +00:00
#[ allow(non_camel_case_types) ]
pub enum __DirectiveLocation {
2020-05-10 04:41:05 +00:00
/// Location adjacent to a query operation.
2020-03-04 06:24:44 +00:00
QUERY ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a mutation operation.
2020-03-04 06:24:44 +00:00
MUTATION ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a subscription operation.
2020-03-04 06:24:44 +00:00
SUBSCRIPTION ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a field.
2020-03-04 06:24:44 +00:00
FIELD ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a fragment definition.
2020-03-04 06:24:44 +00:00
FRAGMENT_DEFINITION ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a fragment spread.
2020-03-04 06:24:44 +00:00
FRAGMENT_SPREAD ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an inline fragment.
2020-03-04 06:24:44 +00:00
INLINE_FRAGMENT ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a variable definition.
2020-03-04 06:24:44 +00:00
VARIABLE_DEFINITION ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a schema definition.
2020-03-04 06:24:44 +00:00
SCHEMA ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a scalar definition.
2020-03-04 06:24:44 +00:00
SCALAR ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an object type definition.
2020-03-04 06:24:44 +00:00
OBJECT ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a field definition.
2020-03-04 06:24:44 +00:00
FIELD_DEFINITION ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an argument definition.
2020-03-04 06:24:44 +00:00
ARGUMENT_DEFINITION ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an interface definition.
2020-03-04 06:24:44 +00:00
INTERFACE ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to a union definition.
2020-03-04 06:24:44 +00:00
UNION ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an enum definition.
2020-03-04 06:24:44 +00:00
ENUM ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an enum value definition.
2020-03-04 06:24:44 +00:00
ENUM_VALUE ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an input object type definition.
2020-03-04 06:24:44 +00:00
INPUT_OBJECT ,
2020-05-10 04:41:05 +00:00
/// Location adjacent to an input object field definition.
2020-03-04 06:24:44 +00:00
INPUT_FIELD_DEFINITION ,
}
pub struct __Directive < ' a > {
pub registry : & ' a registry ::Registry ,
2021-11-11 07:22:40 +00:00
pub visible_types : & ' a HashSet < & ' a str > ,
2020-05-15 02:08:37 +00:00
pub directive : & ' a registry ::MetaDirective ,
2020-03-04 06:24:44 +00:00
}
2020-05-10 04:41:05 +00:00
/// A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
2021-02-23 15:05:08 +00:00
///
/// In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.
2020-10-14 09:08:57 +00:00
#[ Object(internal, name = " __Directive " ) ]
2020-03-05 06:23:55 +00:00
impl < ' a > __Directive < ' a > {
2021-02-27 03:59:58 +00:00
#[ inline ]
2021-02-24 04:06:11 +00:00
async fn name ( & self ) -> & str {
self . directive . name
2020-03-04 06:24:44 +00:00
}
2021-02-27 03:59:58 +00:00
#[ inline ]
2021-02-24 04:06:11 +00:00
async fn description ( & self ) -> Option < & str > {
self . directive . description
2020-03-04 06:24:44 +00:00
}
2021-02-27 03:59:58 +00:00
#[ inline ]
2020-03-28 12:11:26 +00:00
async fn locations ( & self ) -> & Vec < __DirectiveLocation > {
2020-03-05 06:23:55 +00:00
& self . directive . locations
2020-03-04 06:24:44 +00:00
}
2020-03-28 12:11:26 +00:00
async fn args ( & self ) -> Vec < __InputValue < ' a > > {
2020-03-05 06:23:55 +00:00
self . directive
2020-03-04 06:24:44 +00:00
. args
2020-03-08 12:35:36 +00:00
. values ( )
2020-03-04 06:24:44 +00:00
. map ( | input_value | __InputValue {
registry : self . registry ,
2021-11-11 07:22:40 +00:00
visible_types : self . visible_types ,
2020-03-04 06:24:44 +00:00
input_value ,
} )
2020-03-05 06:23:55 +00:00
. collect ( )
2020-03-04 06:24:44 +00:00
}
2021-11-18 12:14:56 +00:00
#[ inline ]
async fn is_repeatable ( & self ) -> bool {
self . directive . is_repeatable
}
2020-03-04 06:24:44 +00:00
}