Struct apollo_compiler::schema::Schema
source · pub struct Schema {
pub sources: SourceMap,
pub schema_definition: Node<SchemaDefinition>,
pub directive_definitions: IndexMap<Name, Node<DirectiveDefinition>>,
pub types: IndexMap<NamedType, ExtendedType>,
/* private fields */
}
Expand description
High-level representation of a GraphQL schema
Fields§
§sources: SourceMap
Source files, if any, that were parsed to contribute to this schema.
The schema (including parsed definitions) may have been modified since parsing.
schema_definition: Node<SchemaDefinition>
The schema
definition and its extensions, defining root operations
directive_definitions: IndexMap<Name, Node<DirectiveDefinition>>
Built-in and explicit directive definitions
types: IndexMap<NamedType, ExtendedType>
Definitions and extensions of built-in scalars, introspection types, and explicit types
Implementations§
source§impl Schema
impl Schema
sourcepub fn new() -> Self
pub fn new() -> Self
Returns an (almost) empty schema.
It starts with built-in directives, built-in scalars, and introspection types. It can then be filled programatically.
sourcepub fn builder() -> SchemaBuilder
pub fn builder() -> SchemaBuilder
Returns a new builder for creating a Schema from AST documents, initialized with built-in directives, built-in scalars, and introspection types
use apollo_compiler::Schema;
let empty_schema = Schema::builder().build();
sourcepub fn validate(&self) -> Result<Diagnostics, Diagnostics>
pub fn validate(&self) -> Result<Diagnostics, Diagnostics>
Returns Err
if invalid, or Ok
for potential warnings or advice
sourcepub fn get_scalar(&self, name: &str) -> Option<&Node<ScalarType>>
pub fn get_scalar(&self, name: &str) -> Option<&Node<ScalarType>>
Returns the type with the given name, if it is a scalar type
sourcepub fn get_object(&self, name: &str) -> Option<&Node<ObjectType>>
pub fn get_object(&self, name: &str) -> Option<&Node<ObjectType>>
Returns the type with the given name, if it is a object type
sourcepub fn get_interface(&self, name: &str) -> Option<&Node<InterfaceType>>
pub fn get_interface(&self, name: &str) -> Option<&Node<InterfaceType>>
Returns the type with the given name, if it is a interface type
sourcepub fn get_union(&self, name: &str) -> Option<&Node<UnionType>>
pub fn get_union(&self, name: &str) -> Option<&Node<UnionType>>
Returns the type with the given name, if it is a union type
sourcepub fn get_enum(&self, name: &str) -> Option<&Node<EnumType>>
pub fn get_enum(&self, name: &str) -> Option<&Node<EnumType>>
Returns the type with the given name, if it is a enum type
sourcepub fn get_input_object(&self, name: &str) -> Option<&Node<InputObjectType>>
pub fn get_input_object(&self, name: &str) -> Option<&Node<InputObjectType>>
Returns the type with the given name, if it is a input object type
sourcepub fn root_operation(
&self,
operation_type: OperationType
) -> Option<&NamedType>
pub fn root_operation( &self, operation_type: OperationType ) -> Option<&NamedType>
Returns the name of the object type for the root operation with the given operation kind
sourcepub fn type_field(
&self,
type_name: &str,
field_name: &str
) -> Result<&Component<FieldDefinition>, FieldLookupError<'_>>
pub fn type_field( &self, type_name: &str, field_name: &str ) -> Result<&Component<FieldDefinition>, FieldLookupError<'_>>
Returns the definition of a type’s explicit field or meta-field.
sourcepub fn is_subtype(&self, abstract_type: &str, maybe_subtype: &str) -> bool
pub fn is_subtype(&self, abstract_type: &str, maybe_subtype: &str) -> bool
Returns whether maybe_subtype
is a subtype of abstract_type
, which means either:
maybe_subtype
implements the interfaceabstract_type
maybe_subtype
is a member of the union typeabstract_type
sourcepub fn is_input_type(&self, ty: &Type) -> bool
pub fn is_input_type(&self, ty: &Type) -> bool
Returns whether the type ty
is defined as is an input type
https://spec.graphql.org/October2021/#sec-Input-and-Output-Types
sourcepub fn is_output_type(&self, ty: &Type) -> bool
pub fn is_output_type(&self, ty: &Type) -> bool
Returns whether the type ty
is defined as is an output type
https://spec.graphql.org/October2021/#sec-Input-and-Output-Types
Trait Implementations§
source§impl PartialEq for Schema
impl PartialEq for Schema
impl Eq for Schema
Auto Trait Implementations§
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.