pub struct Field<'a> {
pub alias: Option<&'a str>,
pub name: &'a str,
pub arguments: Arguments<'a>,
pub directives: Directives<'a>,
pub selection_set: SelectionSet<'a>,
}
Expand description
AST Node for Fields, which can be likened to functions or properties on a parent object.
In JSON this would represent a property in a JSON object. Reference
Fields§
§alias: Option<&'a str>
A Field’s alias
, which is used to request information under a different name than the
Field’s name
.
Reference
name: &'a str
A Field’s name
, which represents a resolver on a GraphQL schema’s object type.
arguments: Arguments<'a>
Arguments that are passed to a Field.
When no Arguments are passed, this will be an empty
list, as can be checked using Arguments::is_empty
.
See: Arguments
directives: Directives<'a>
Directives that are annotating this Field.
When no Directives are present, this will be an empty
list, as can be checked using Directives::is_empty
.
See: Directives
selection_set: SelectionSet<'a>
A sub-Selection Set that is passed below this field to add selections to this field’s returned GraphQL object type.
When no selections are present, this will be an empty
list, as can be checked using SelectionSet::is_empty
.
See: SelectionSet
Implementations§
Source§impl<'a> Field<'a>
impl<'a> Field<'a>
Sourcepub fn alias_or_name(&self) -> &'a str
pub fn alias_or_name(&self) -> &'a str
Get the alias of the field, if present, otherwise get the name.
Sourcepub fn new_leaf(ctx: &'a ASTContext, name: &'a str) -> Self
pub fn new_leaf(ctx: &'a ASTContext, name: &'a str) -> Self
Creates a new leaf field with the given name
.
All sub-lists, like arguments
, directives
and selection_set
will be created as empty
defaults.
Sourcepub fn new_aliased_leaf(
ctx: &'a ASTContext,
alias: &'a str,
name: &'a str,
) -> Self
pub fn new_aliased_leaf( ctx: &'a ASTContext, alias: &'a str, name: &'a str, ) -> Self
Creates a new leaf field with the given name
and alias
.
All sub-lists, like arguments
, directives
and selection_set
will be created as empty
defaults.