fn default_transform_operation()

in compiler/crates/graphql-ir/src/transform.rs [99:129]


    fn default_transform_operation(
        &mut self,
        operation: &OperationDefinition,
    ) -> Transformed<OperationDefinition> {
        let selections = self.transform_selections(&operation.selections);
        let directives = self.transform_directives(&operation.directives);
        let variable_definitions =
            self.transform_variable_definitions(&operation.variable_definitions);

        // Special-case for empty selections
        if let TransformedValue::Replace(selections) = &selections {
            if !Self::RETAIN_EMPTY_SELECTION_SETS && selections.is_empty() {
                return Transformed::Delete;
            }
        }

        if variable_definitions.should_keep()
            && directives.should_keep()
            && selections.should_keep()
        {
            return Transformed::Keep;
        }

        Transformed::Replace(OperationDefinition {
            variable_definitions: variable_definitions
                .replace_or_else(|| operation.variable_definitions.clone()),
            directives: directives.replace_or_else(|| operation.directives.clone()),
            selections: selections.replace_or_else(|| operation.selections.clone()),
            ..operation.clone()
        })
    }