Low Performance at first query

Created on 6 August 2025, 25 days ago

Problem/Motivation

When using graphql-compose with Drupal, the first GraphQL request after a cache clear or process restart takes significantly longer (5-6 seconds), while subsequent requests are much faster. This negatively impacts user experience and system responsiveness, especially in environments with frequent process restarts (e.g., PHP-FPM).

Steps to reproduce

- Clear Drupal caches or restart the PHP process.
- Send a GraphQL query via graphql-compose.
- Observe that the first request is slow (5-6 seconds).
- Send the same query again; the response is much faster (almost instant).

Proposed resolution

Investigate ways to persist the generated GraphQL schema between requests/processes, or optimize the schema build process so that the first request is not significantly slower. Consider implementing a persistent schema cache using APCu, Redis, or file-based storage, or provide a mechanism for pre-building/warming up the schema.

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @tarikflz
  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    When you say it takes 5-6 seconds on a cold cache, is that all of drupal or only graphql compose? Like, if you clear your cache, and go to the homepage, is it 5-6 seconds?

    Also how complex is your query? Compose isn't really doing anything special with cache. Load more, slow more.

    It's almost guaranteed there could be performance bottlenecks. I just dont have the insight to your app to know what that is! Help is always appreciated.

    The GraphQL module has built-in support for persisted queries via plugins. I haven't used it, but maybe thats an angle?

Production build 0.71.5 2024