GraphQL query stops working - seems cache issue

Created on 27 September 2024, 7 months ago

Problem/Motivation

GraphQL query suddenly stops working. After clearing all cache multiple time it starts working. It's happening in our prod environment.

Steps to reproduce

When I navigate to run query here `/admin/config/graphql/servers/manage/graphql_compose_server/explorer`. I'm seeing so many errors:
{
"errors": [
{
"message": "Interface field Connection.nodes expects type [EdgeNode!]! but BlockContentAlertConnection.nodes is type [BlockContentAlert!]!.",
"stack": "GraphQLError: Interface field Connection.nodes expects type [EdgeNode!]! but BlockContentAlertConnection.nodes is type [BlockContentAlert!]!.\n at t.reportError (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at w (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at E (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at h (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at Object.Xa [as useMemo] (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at t.useMemo (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at SchemaContextProvider (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at ka (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)"
},
{
"message": "Interface field Edge.node expects type EdgeNode! but BlockContentAlertEdge.node is type BlockContentAlert!.",
"stack": "GraphQLError: Interface field Edge.node expects type EdgeNode! but BlockContentAlertEdge.node is type BlockContentAlert!.\n at t.reportError (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at w (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at E (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at h (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at Object.Xa [as useMemo] (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at t.useMemo (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at SchemaContextProvider (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at ka (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)"
},
{
"message": "Interface field Connection.nodes expects type [EdgeNode!]! but BlockContentAuthorSBlockConnection.nodes is type [BlockContentAuthorSBlock!]!.",
"stack": "GraphQLError: Interface field Connection.nodes expects type [EdgeNode!]! but BlockContentAuthorSBlockConnection.nodes is type [BlockContentAuthorSBlock!]!.\n at t.reportError (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at w (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at E (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at h (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at Object.Xa [as useMemo] (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at t.useMemo (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at SchemaContextProvider (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at ka (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)"
},
{
"message": "Interface field Edge.node expects type EdgeNode! but BlockContentAuthorSBlockEdge.node is type BlockContentAuthorSBlock!.",
"stack": "GraphQLError: Interface field Edge.node expects type EdgeNode! but BlockContentAuthorSBlockEdge.node is type BlockContentAuthorSBlock!.\n at t.reportError (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at w (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at E (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at h (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...\n at Object.Xa [as useMemo] (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at t.useMemo (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at SchemaContextProvider (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)\n at ka (https://wwwassets.tuftshealthplan.com/modules/contrib/graphql/assets/exp...)"
},
}

Proposed resolution

When I clear Drupal cache multiple times, not sure it suddenly starts working. Issue is bit strange but not sure why it's happening.

Remaining tasks

NA

User interface changes

NA

API changes

NA

Data model changes

NA

๐Ÿ› Bug report
Status

Needs work

Version

4.8

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia pradeepjha

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

Comments & Activities

  • Issue created by @pradeepjha
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pradeepjha

    It's breaking our prod site when GraphQL suddenly stops giving response. Lower environment it looks good. That's why increasing priority.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States cruno NJ

    Confirming that this is an issue we are also experiencing. We use graphql_compose to generate schema.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom james.south

    I need to debug further but I'm observing the same behaviour on a site with GraphQL 8.x-4.9 and GraphQL Compose 2.2.1.

    In our case all queries fail until the cache is rebuilt (a single cache clear consistently fixes the issue temporarily). Issue is sporadic and we haven't identified a consistent trigger for it.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia shabana.navas

    We're running GraphQL 8.x-4.8 and are seeing the same issue w/ GraphQL queries not working after each deploy to production. We don't use GraphQL Compose.

    A query to get the Commerce Orders in the GraphQL explorer, returns errors like this:

    {
        "errors": [
            {
                "message": "Cannot query field \u0022derivative\u0022 on type \u0022FieldItemTypeImage\u0022.",
                "extensions": {
                    "category": "graphql"
                },
                "locations": [
                    {
                        "line": 88,
                        "column": 25
                    }
                ]
            },
            {
                "message": "Cannot query field \u0022derivative\u0022 on type \u0022FieldItemTypeImage\u0022.",
                "extensions": {
                    "category": "graphql"
                },
                "locations": [
                    {
                        "line": 121,
                        "column": 25
                    }
                ]
            },
    ...
    

    After clearing cache a couple of more times, it starts working again.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium matthieu_collet

    Any update on this error ?
    We suddenly have it too since this morning, our production site is broken, and clear cache doesn't solve anything :(

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium davidiio

    Hello,

    We face the same issue here once with an apdated site (we restored backups to make it work again) and now we face it with a new dev website with Drupal 11.1.5 and GraphQL 8.x-4.11 and Graphql_compose 2.3.0.

    We noticed this error GraphQL\Error\SyntaxError : Syntax Error: Cannot parse the unexpected character "\uc9". dans GraphQL\Language\Lexer->readToken()

    And realized that this bug happend only after translation updates, if we revert our prod site, enable a new module that updates translation we have this bug again.
    Are any of you using multilingual sites? Maybe this is a lead to find out what is wrong here?

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium davidiio

    After some disabling and enabling of graphQL and GraphQL Compose and returning to the explorer page between modifications we also notice that unticking the "Enable Singuliarize" checkbox in the "String inflector" tab of graphql_compose settings produces the same bug.
    Maybe this issue is a graphql_compose issue and not a graphql issue.

  • ๐Ÿ‡จ๐Ÿ‡ทCosta Rica esteban.arias

    Heya everyone,

    If you are using graphql while also using memcache as your default cache backend, please introduce these lines to your settings:

    $settings['cache']['bins']['graphql_ast'] = 'cache.backend.database';
    $settings['cache']['bins']['graphql_results'] = 'cache.backend.database';

    This should let graphql use the database tables for caching purposes which seems to make the random issues go away.

    I didn't find this fix by myself but got permission to share it to the community.

    Hope this helps!

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Looks like the changes in ๐Ÿ› Cache collision when multiple servers are using the same schema plugin Active are breaking.

    web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php

    Method: getCacheId

    $this->getConfiguration()['server_id'] is not always set. It's weirdly only sometimes set?

    It looks like its set in the server and not the schema?

    Full ID returned: full:graphql_compose:my_server
    - /admin/config/graphql/servers/manage/core_graphql/explorer
    - /admin/config/graphql/servers/manage/core_graphql/voyager

    Partial ID returned: full:graphql_compose
    - /admin/config/graphql/servers/manage/core_graphql/validate

    Somethings not right or I'm missing something here.
    Is it an order or operation or missing data?

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    I'm unsure, quick check and maybe this was missed, and it fixes the issue?

    $cid = $this->getCacheId('schema');
    for web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php

  • @almunnings opened merge request.
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Side note: I still feel like it a bandaid on the symptom, and it's still going to be getting that deprecated in getCacheId, all we're doing is separating the caches by adding in the getCacheId again.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ
  • Seeing the same issue on a site with translation, also using compose, truncating the cache tables seem to be the only fix.

    Explorer shows none of the schema, but just found if I can to graphql compose and save configuration it fixes the issue, so seems like it more likely a compose issue

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Compose nukes all GraphQL caches on save. That could be what youโ€™re seeing.

Production build 0.71.5 2024