pub fn partial_execute(
schema: &Valid<Schema>,
implementers_map: &HashMap<Name, Implementers>,
document: &Valid<ExecutableDocument>,
operation: &Operation,
variable_values: &Valid<JsonMap>,
) -> Result<ExecutionResponse, RequestError>
Expand description
Excecutes the schema introspection portion of a query and returns a partial response.
- Consider calling
check_max_depth
before this function implementers_map
is expected to be formschema.implementers_map()
, allowing it to be computed once and reused for many queriesoperation
is expected to be fromdocument.operations.get(operation_name)?
operation
is expected to be a query, checkoperation.operation_type.is_query()
variable_values
is expected to be fromcoerce_variable_values
Concrete root fields (those with an explicit definition in the schema) are silently ignored.
Only introspection meta-fields are executed:
__typename
(at the response root), __type
, and __schema
.
If the operation also contains concrete fields,
the caller can execute them separately and merge the two partial responses.
To categorize which kinds of root fields are present, consider using code like:
let mut has_schema_introspection_fields = false;
let mut has_root_typename_fields = false;
let mut has_concrete_fields = false;
for root_field in operation.root_fields(document) {
match root_field.name.as_str() {
"__type" | "__schema" => has_schema_introspection_fields = true,
"__typename" => has_root_typename_fields = true,
_ => has_concrete_fields = true,
}
}