Automattic\WooCommerce\Vendor\GraphQL\Utils

BreakingChangesFinder::findTypesThatChangedKindpublic staticWC 1.0

Given two schemas, returns an Array containing descriptions of any breaking changes in the newSchema related to changing the type of a type.

Method of the class: BreakingChangesFinder{}

No Hooks.

Returns

Array. Change>

Usage

$result = BreakingChangesFinder::findTypesThatChangedKind( $schemaA, $schemaB ): array;
$schemaA(Schema) (required)
.
$schemaB(Schema) (required)
.

BreakingChangesFinder::findTypesThatChangedKind() code WC 10.9.1

public static function findTypesThatChangedKind(
    Schema $schemaA,
    Schema $schemaB
): array {
    $schemaATypeMap = $schemaA->getTypeMap();
    $schemaBTypeMap = $schemaB->getTypeMap();

    $breakingChanges = [];
    foreach ($schemaATypeMap as $typeName => $schemaAType) {
        if (! isset($schemaBTypeMap[$typeName])) {
            continue;
        }

        $schemaBType = $schemaBTypeMap[$typeName];
        if ($schemaAType instanceof $schemaBType) {
            continue;
        }

        if ($schemaBType instanceof $schemaAType) {
            continue;
        }

        $schemaATypeKindName = self::typeKindName($schemaAType);
        $schemaBTypeKindName = self::typeKindName($schemaBType);
        $breakingChanges[] = [
            'type' => self::BREAKING_CHANGE_TYPE_CHANGED_KIND,
            'description' => "{$typeName} changed from {$schemaATypeKindName} to {$schemaBTypeKindName}.",
        ];
    }

    return $breakingChanges;
}