The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

1090 Modules
628 Ready
462 Need Help
🏆 Leaderboard
Stable v1.1.6

Sterk GraphQL Performance

veysiyildiz/module-graphql-performance

Optimizes Magento 2 GraphQL performance with DataLoader-based batch loading to prevent N+1 queries, multi-level caching with cache warming, and query-complexity and performance monitoring.

9
Downloads
Below average
18
GitHub Stars
Below average
11mo ago
Last Release
0
Open Issues
Build Issues
0/3 checks passed

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
PHPStan

Tested on Magento 2.4.9

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.1.6 on Magento 2.4.9
Jun 3, 2026

Looking for Contributors

Composer installation fails. Your contribution could help the entire Magento community!

Contribute

Share This Module's Status

Sterk GraphQL Performance Magento compatibility status badge

README

Loaded from GitHub

Sterk GraphQL Performance Module for Magento 2

Overview

The Sterk GraphQL Performance module is a comprehensive solution for optimizing GraphQL performance in Magento 2. It addresses common performance bottlenecks, implements efficient data loading patterns, and provides robust caching strategies.

Features

1. Data Loading Optimization

  • DataLoader pattern implementation for batch loading
  • Prevention of N+1 query problems
  • Efficient data retrieval for:
    • Products
    • Categories
    • Customers
    • CMS Pages/Blocks
    • Orders and Invoices
    • Brand Categories
    • Credit Memos

2. Caching Infrastructure

  • Multi-level caching strategy
  • Intelligent cache tag management
  • Automatic cache warming
  • Query-level caching
  • Field-level result caching
  • Cache invalidation optimization

3. Performance Monitoring

  • Query execution time tracking
  • Performance metrics collection
  • GraphQL query complexity analysis
  • Resource usage monitoring
  • Performance reporting

4. Database Optimization

  • Connection pooling
  • Transaction management
  • Batch query optimization
  • Efficient resource utilization

Installation

  1. Install via Composer:
composer require veysiyildiz/module-graphql-performance
  1. Enable the module:
bin/magento module:enable Sterk_GraphQlPerformance
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:clean

Configuration

Admin Configuration

Navigate to Stores > Configuration > Sterk > GraphQL Performance to configure:

  1. Cache Settings

    • Cache lifetime for different entities
    • Cache warming patterns
    • Cache invalidation rules
  2. Performance Limits

    • Query complexity limits
    • Query depth restrictions
    • Batch size configurations
  3. Monitoring Settings

    • Performance logging
    • Metric collection
    • Report generation

Cache Warming Configuration

Configure cache warming in etc/config.xml:

<config>
    <default>
        <graphql_performance>
            <cache>
                <warming_enabled>1</warming_enabled>
                <warming_interval>3600</warming_interval>
            </cache>
        </graphql_performance>
    </default>
</config>

Usage

Basic Implementation

use Sterk\GraphQlPerformance\Model\DataLoader\ProductDataLoader;

class ProductResolver implements ResolverInterface
{
    public function __construct(
        private readonly ProductDataLoader $dataLoader
    ) {}

    public function resolve(
        Field $field,
        $context,
        ResolveInfo $info,
        array $value = null,
        array $args = null
    ) {
        return $this->dataLoader->load($args['id']);
    }
}

Advanced Features

Custom DataLoader

use Sterk\GraphQlPerformance\Model\DataLoader\BatchDataLoader;

class CustomDataLoader extends BatchDataLoader
{
    protected function loadFromDatabase(array $ids): array
    {
        // Implement batch loading logic
    }

    protected function generateCacheKey(string $id): string
    {
        return "custom_entity_{$id}";
    }
}

Cache Tag Management

use Sterk\GraphQlPerformance\Model\Cache\TagManager;

class CustomResolver
{
    public function __construct(
        private readonly TagManager $tagManager
    ) {}

    public function resolve($field)
    {
        $tags = $this->tagManager->getEntityTags('custom_entity', $id);
        // Use tags for cache operations
    }
}

Performance Monitoring

Metrics Collection

The module automatically collects:

  • Query execution times
  • Cache hit rates
  • Database query counts
  • Memory usage
  • Query complexity scores

Reporting

Access performance reports via:

  1. GraphQL API endpoint
  2. Admin dashboard
  3. Command line interface

Best Practices

1. Query Optimization

  • Use field selection wisely
  • Implement pagination
  • Leverage query batching
  • Monitor query complexity

2. Caching Strategy

  • Configure appropriate cache lifetimes
  • Use specific cache tags
  • Implement proper invalidation
  • Enable cache warming

3. Resource Management

  • Configure connection pooling
  • Monitor memory usage
  • Implement query timeouts
  • Use batch processing

Troubleshooting

Common Issues

  1. Cache Invalidation
Issue: Stale data after updates
Solution: Check cache tags and invalidation events
  1. Performance Degradation
Issue: Slow query response
Solution: Monitor query complexity and database connections
  1. Memory Usage
Issue: High memory consumption
Solution: Adjust batch sizes and connection pool settings

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE.md for details

Support

For support, please:

  1. Check documentation
  2. Search existing issues
  3. Create a new issue
  4. Contact veysiyildiz@gmail.com

Changelog

See CHANGELOG.md for version history

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.