nuwave / nuwave/lighthouse

QueryCache returns __PHP_Incomplete_Class on Laravel 13

Open
#2,782 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.5k
Forks
468
Avg merge
3h 9m
Merged PRs (30d)
2

Description

After upgrading our application framework from Laravel 12 to Laravel 13, using Redis as the backing store for Lighthouse's query cache query_cache.mode = 'store', requests fail with the following type error:

{
    "errors": [
        {
            "message": "Internal server error",
            "extensions": {
                "debugMessage": "Nuwave\\Lighthouse\\Cache\\QueryCache::fromStoreOrParse(): Return value must be of type GraphQL\\Language\\AST\\DocumentNode, __PHP_Incomplete_Class returned",
                "file": "/var/www/html/vendor/nuwave/lighthouse/src/Cache/QueryCache.php",
                "line": 84,
                "trace": [
                    {
                        "file": "/var/www/html/vendor/nuwave/lighthouse/src/Cache/QueryCache.php",
                        "line": 72,
                        "call": "Nuwave\\Lighthouse\\Cache\\QueryCache::fromStoreOrParse()"
                    },
                    {
                        "file": "/var/www/html/vendor/nuwave/lighthouse/src/GraphQL.php",
                        "line": 287,
                        "call": "Nuwave\\Lighthouse\\Cache\\QueryCache::fromCacheOrParse()"
                    },
....
Steps to reproduce
  • Upgrade Laravel application to Laravel 13.
  • Set up a dedicated cache store in config/cache.php enabling serializable_classes:
'graphql_cache' => array_merge([
    'driver' => env('CACHE_STORE', 'database'),
    'serializable_classes' => true,
], env('CACHE_STORE') === 'database' ? [
    'table' => 'cache',
    'connection' => null,
] : []),
  • Ensure the underlying redis driver configuration in config/cache.php also includes 'serializable_classes' => true:
'redis' => [
    'driver' => 'redis',
    'connection' => env('REDIS_CACHE_CONNECTION', 'default'),
    'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
    'serializable_classes' => true,
],
  • Configure Lighthouse to use the store in config/lighthouse.php
'query_cache' => [
    'enable' => true,
    'store' => 'graphql_cache',
    'mode' => 'store',
],
  • Execute any valid GraphQL query against the application.
  • Trigger a second request with the same query so it hits the Redis cache store.
Expected behavior / Solution

Expected behavior: Lighthouse should successfully retrieve and unserialize the cached GraphQL\Language\AST\DocumentNode instance from the Redis store without throwing a type error.

PHP Version 8.4.23
Lighthouse Version 6.66.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with vendor/nuwave/lighthouse/src/Cache/QueryCache.php at fromStoreOrParse() and fromCacheOrParse(), then review the serializable_classes settings in config/cache.php and config/lighthouse.php. Reproduce the first and second requests against the Redis-backed query cache; done means the cached GraphQL DocumentNode is retrieved without a __PHP_Incomplete_Class type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php, redis
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.