2020-03-04 06:24:44 +00:00
use crate ::model ::__InputValue ;
2020-03-05 06:23:55 +00:00
use crate ::registry ;
2020-03-04 06:24:44 +00:00
use async_graphql_derive ::{ Enum , Object } ;
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.
#[ Enum(internal) ]
2020-04-08 01:05:54 +00:00
#[ derive(Debug) ]
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 ,
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.
//
// 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.
#[ Object(internal) ]
2020-03-05 06:23:55 +00:00
impl < ' a > __Directive < ' a > {
2020-03-28 12:11:26 +00:00
async fn name ( & self ) -> String {
2020-03-05 06:23:55 +00:00
self . directive . name . to_string ( )
2020-03-04 06:24:44 +00:00
}
2020-03-28 12:11:26 +00:00
async fn description ( & self ) -> Option < String > {
2020-03-05 06:23:55 +00:00
self . directive . description . map ( | s | s . to_string ( ) )
2020-03-04 06:24:44 +00:00
}
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 ,
input_value ,
} )
2020-03-05 06:23:55 +00:00
. collect ( )
2020-03-04 06:24:44 +00:00
}
}