Disabling singulizarize break graphQL

Created on 1 April 2025, 5 days ago

We are using graphql_compose 2.3 on druapl 11.1.5 on a multilingual site.

When disabling Singuliarize option in the string inflector panel of the graphQL compose settings we can't use graphQL anymore. When we go on the explorer page we have a white screen with message "this website..." with an error in Drupal watchdog (see below) and when we refresh we have the explorer but in the response panel there is a long error.

Here is the watchdog error about webonyx not able to parse a special character (that is why I mentioned we are on a multilingual setup)
GraphQL\Error\SyntaxError : Syntax Error: Cannot parse the unexpected character "\uc9". dans GraphQL\Language\Lexer->readToken() (ligne 282 de [path to]/vendor/webonyx/graphql-php/src/Language/Lexer.php).

Then after refreshing the explorer here are some of the error messages we see in response panel:

"Type Query must define one or more fields.",
"Interface field Edge.node expects type EdgeNode! but MediaDocumentEdge.node is type MediaDocument!.",
"Interface field Connection.nodes expects type [EdgeNode!]! but MediaImageConnection.nodes is type [MediaImage!]!.",
"Interface field Connection.nodes expects type [EdgeNode!]! but MediaRemoteVideoConnection.nodes is type [MediaRemoteVideo!]!."

If we just let Singuliarize option checked then everything is still working.

When looking for a solution I found this issues with similar errors but people have found that clearing the cache helped which is not the case for me.
https://www.drupal.org/project/graphql/issues/3477239 🐛 GraphQL query stops working - seems cache issue Needs work

🐛 Bug report
Status

Active

Version

2.3

Component

Code

Created by

🇧🇪Belgium davidiio

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

Comments & Activities

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

    Yeah strange,
    How are you getting the É character into your schema...!

    The GraphQL error is a symptom.
    I saw it just now when switching between graphql 4 and 5-dev.

    Are you using 5-dev by chance? Somehow using graphql webonyx 15?
    If so, does switching to 📌 Add GraphQL 5.x support Active and clearing your cache have any positive effect?

    If not...
    HMM!

    Are you injecting your own data from somewhere else?
    The only way I was able to reproduce was to put the É character in a fieldname.

    Do you have any idea where that field is coming from?

  • 🇧🇪Belgium davidiio

    Thanks for your answer!

    We are using graphQL Version : 8.x-4.11
    Following the stacktrace the webonyx error goes back to graphql module

    /web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/AlterableComposableSchema.php(173): GraphQL\Language\Parser::parse('extend type Que...', Array)

    When logging the $extensions variable it is trying to parse I have found a very long string. It looks like all the content types and terms we exposed with graphql_compose and in this string some words appear in French especialy the word "Element" is translated to "Élément" in different places like

     extend type Query {
          """List of all TermTags on the platform."""
          termTagsÉléments(
            """Returns the elements that come after the specified cursor."""
            after: Cursor
    

    or in this part that looks like a view on which we exposed the number of "element per page"

            """The page number to display."""
            page: Int = 0
            """Éléments par page. Allowed values are: 5, 10, 12, 20, 24, 25, 50."""
            pageSize: Int = 20
    

    I was able to remove the É from the "Éléments par page" by configuring the view but other strings like "termTagsÉléments" remain even when remmoving all accents from "Element" in /admin/config/regional/translate

    This is a weird string because only the "Element" word is translated and it is translated event on part of words like in "termTagsÉléments".
    We had this same issue on a prod site when activating a module and some translations were updated. Is it possible that core translation introduced some bug?

  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Ok cool, that helps me narrow it down.
    I'll put $2 on it being this line:

    https://git.drupalcode.org/project/graphql_compose/-/blob/2.4.x/src/Lang...

    Could you try change that locally to 'items' instead of $this->t('items')
    If that works, we might either leave it as t and strip back the higher ascii.

    Thanks for your help!

  • 🇧🇪Belgium davidiio

    YES :)
    Changing $this->t('items') to 'items' does eliminate error for us.

    Thanks a lot!

  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Aighty cool.
    So I guess, as you are the resident French speaker.

    if I changed
    Éléments
    to
    Elements

    In this scenario, would it be acceptable?

  • 🇧🇪Belgium davidiio

    Yes, I suppose.
    In french element is supposed to be "élément" (if displayed to a human reading french) but these strings are not supposed to be displayed so it is ok without accent, I would never name a variable with accents.

  • 🇦🇺Australia almunnings Melbourne, 🇦🇺
  • @almunnings opened merge request.
  • 🇧🇪Belgium davidiio

    I have used your merge request .diff file (https://git.drupalcode.org/project/graphql_compose/-/merge_requests/120....) on Drupal 11.1.5, graphql 8.x-4.11, graphql_compose 2.3.0. It applies and singuliarize option can be on or off without error.

    I might not be the best to say it is RTBC, but for me, it is working :)
    Thanks!

  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Good enough for me!

    RE the other error you noticed, thats related to 🐛 GraphQL query stops working - seems cache issue Needs work I'm pretty sure.
    I'll merge this one in now.

    Cheers

  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Merged to next release

Production build 0.71.5 2024