yireo / magento2-graph-ql-schema-manipulation

yireo/magento2-graph-ql-schema-manipulation

Magento module to manipulate the GraphQl schema

magento2-module Compatibility: 2.4.7-2.4.9 Code Quality: Fail Tests: Fail Security: Pass OSL-3.0

Yireo GraphQlSchemaManipulation

Magento version
PHP version
License
Latest Version

Magento 2 module to manipulate the GraphQL schema before it is being used. This can be useful when trying to remove endpoints that are added by monolithic extensions and perhaps other use-cases.

Installation

composer require yireo/magento2-graph-ql-schema-manipulation
bin/magento module:enable Yireo_GraphQlSchemaManipulation

Usage

To manipulate the schema, create a class that implements SchemaConfigManipulatorInterface. It receives the full schema config (as read from all schema.graphqls files), keyed by type name. Use the SchemaConfigEditor to remove fields, arguments and enum values of a specific type:

use Yireo\GraphQlSchemaManipulation\Schema\SchemaConfigEditor;
use Yireo\GraphQlSchemaManipulation\Schema\SchemaConfigManipulatorInterface;

class ExampleSchemaManipulator implements SchemaConfigManipulatorInterface
{
    public function __construct(
        private readonly SchemaConfigEditor $schemaConfigEditor
    ) {
    }

    public function manipulate(array $schemaConfig): array
    {
        $schemaConfig = $this->schemaConfigEditor->removeField($schemaConfig, 'Query', 'isEmailAvailable');
        $schemaConfig = $this->schemaConfigEditor->removeArgument($schemaConfig, 'Query', 'products', 'search');
        return $this->schemaConfigEditor->removeEnumValue($schemaConfig, 'CurrencyEnum', 'EUR');
    }
}

When a field or argument is removed from an interface (like ProductInterface), it is also removed from all types implementing that interface (like SimpleProduct), so the schema stays consistent. A field with the same name in another type or input is left alone.

Next, add this class to this module with a global etc/di.xml file (not etc/graphql/di.xml, because the schema config is cached once for all areas):

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Yireo\GraphQlSchemaManipulation\Plugin\ManipulateSchemaConfig">
        <arguments>
            <argument name="schemaConfigManipulators" xsi:type="array">
                <item name="example" xsi:type="object">ExampleSchemaManipulator</item>
            </argument>
        </arguments>
    </type>
</config>

The manipulated schema config is stored in the config cache. After changing a manipulator, run bin/magento cache:clean config. If a manipulator returns an invalid schema config, a LogicException naming the manipulator is thrown.

Limitations

Removing a field from the GraphQL schema only hides it from GraphQL: queries for it fail validation and introspection no longer shows it. It does not disable the underlying feature. Resolver classes, REST endpoints (like V1/customers/isEmailAvailable) and controllers offering the same functionality are still available. Do not rely on this module as your only access control.

Deprecated: ManipulationInterface

The older ManipulationInterface (added to Plugin\AddSchemaManipulators via its schemaManipulators argument) still works, but is deprecated. Its manipulateFieldsConfig() method receives the Magento\Framework\GraphQl\Config\Element\Field objects of every single type, input and interface, without the type name. Removing a field by name therefore removes it from every type and input that has a field with that name.

Current status

Static Tests
Unit Tests
Integration Tests
Playwright
DI Compilation

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.

[Unreleased]

[0.0.3] - 25 November 2026

Added

  • Schema config manipulators (SchemaConfigManipulatorInterface) that receive the GraphQL schema config keyed by type name, so fields, arguments and enum values can be removed from one specific type; removing from an interface also removes it from the implementing types
  • Field manipulators now also apply to interface fields, which were skipped before
  • Support for PHP 8.4 and 8.5
  • README documentation of schema config manipulators and their limits

Changed

  • The field-level ManipulationInterface is deprecated in favour of schema config manipulators
  • Manipulator output is now validated, giving a clear error when a manipulator returns invalid data

Removed

  • Support for PHP 8.1
Versions
Version Stability QA Status Compatibility Released
0.0.3 stable Fail Magento 2.4.7-2.4.9 Details 2026-11-25 08:10:50
0.0.2 stable Fail Not yet tested Details 2025-02-03 13:47:55
0.0.1 stable Not tested Not yet tested Details 2024-08-06 18:40:17

Requires 2

Package Constraint
magento/framework ^103.0
php >=8.2 <8.6

Requires-dev 2

Package Constraint
phpunit/phpunit ^10.5
yireo/magento2-integration-test-helper ~0.0

Compatibility

Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.

Compatibility matrix (Magento × PHP)
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 Pass Pass
2.4.8 Pass Pass
2.4.9 Pass Pass

Code Quality

Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge. A phpcs finding can't make a module incompatible.

Static analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

Static analysis results
Tool Status Findings Summary
PHPCS Pass 0
PHPMD Warning 6 6 rule violations (UnusedFormalParameter:5, CyclomaticComplexity:1)
Cpd Pass 0
Composer validate Info 1 valid; 1 advisory note (composer validate --strict)

PHPStan

Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases.

PHPStan results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 4 4
2.4.8 4 4
2.4.9 4 4

Tests

Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.

Unit tests

Unit tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Integration tests

Integration tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 Pass Pass
2.4.8 Pass Pass
2.4.9 Pass Error

Security

Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.

Security results
Tool Status Findings Summary
Composer audit Pass 0
Malware scan Pass 0
License
OSL-3.0

More from yireo

View vendor
Make it pay

Turn an existing module into recurring revenue.

If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.