pub enum SchemaIntrospectionSplit {
None,
Only(SchemaIntrospectionQuery),
Both {
introspection_query: SchemaIntrospectionQuery,
filtered_document: Valid<ExecutableDocument>,
},
}
Expand description
Result of split
ting schema introspection fields from an operation.
Variants§
None
The selected operation does not use schema introspection fields. It should be executed unchanged.
Only(SchemaIntrospectionQuery)
The selected operation only uses schema introspection fields.
This provides the execute
’able introspection query,
there is nothing else to execute.
Both
Fields
introspection_query: SchemaIntrospectionQuery
The execute
’able query
for schema introspection parts of the original operation.
filtered_document: Valid<ExecutableDocument>
The rest of the operation.
This document contains exactly one operation with schema introspection fields removed,
and the fragment definitions that are still needed.
The operation definition name is preserved,
so either None
or the original Option<&str>
name request can be passed
to ExecutableDocument::get_operation
to obtain the one operation.
The selected operation uses both schema introspection fields and other fields.
Each part should be executed, and their responses merged with Response::merge
.
Implementations§
source§impl SchemaIntrospectionSplit
impl SchemaIntrospectionSplit
sourcepub fn split(
schema: &Valid<Schema>,
document: &Valid<ExecutableDocument>,
operation: &Node<Operation>
) -> Result<Self, SchemaIntrospectionError>
pub fn split( schema: &Valid<Schema>, document: &Valid<ExecutableDocument>, operation: &Node<Operation> ) -> Result<Self, SchemaIntrospectionError>
Splits schema introspection fields from an operation.
Returns either a split result, or a request error that should stop any further execution
and can be converted with into_response
.
In the execution model described in the GrapQL specification, a single server executes an entire operation by traversing its selections and calling resolver functions for each individual field. In this model, schema introspection is just another set of fields with dedicated resolver functions.
In other models such as Apollo Federation there may not be an obvious place
to “plug in” such resolvers. Instead, this function splits an operation
into either or both introspection and other parts that can be executed separately.
Full execution of introspection parts is provided by SchemaIntrospectionQuery::execute
.
In an unconventional schema
where the type of the query
operation is also the type of some field,
it is possible to use schema introspection fields nested in other fields.
This function returns SchemaIntrospectionError::Unsupported
for such operations,
as they cannot be split into parts that have disjoint response keys.