Undefined array key "extensions"

Created on 16 April 2024, 8 months ago
Updated 5 May 2024, 8 months ago

Problem/Motivation

After updating from 2.1.0-beta1 to 2.1.0-beta4, when i tried to access my endpoint or use the explorer i got the following warning.

Warning: Undefined array key "extensions" in Drupal\graphql\Plugin\GraphQL\Schema\ComposableSchema->getExtensions() (line 34 of /app/cms/web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/ComposableSchema.php)
And following error
TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter() (line 34 of /app/cms/web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/ComposableSchema.php).

Might be related to https://github.com/drupal-graphql/graphql/issues/1395.

๐Ÿ› Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium cedricl

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

Merge Requests

Comments & Activities

  • Issue created by @cedricl
  • Assigned to abhishek_virasat
  • Merge request !72fix the issue โ†’ (Closed) created by abhishek_virasat
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhishek_virasat

    @CedricL, I have fixed the issue and created MR. please review it once

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

    Not sure thats it, `getDefinitions` should always return an array. I feel we have a bigger issue with merging non graphql_compose schemas into the final result.

  • Pipeline finished with Success
    8 months ago
    Total: 611s
    #147936
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Ok, it probably boils down to...
    $this->getConfiguration()['extensions']

    I'll take a look deeper there tonight after everyone goes to bed :)

    There was some schema changes upstream in GraphQL which I had to try work with.

    Can you try going to the GraphQL schema in the GraphQL admin interface, and just clicking "save" ?

    Eg URL: /admin/config/graphql/servers/manage/YOUR-CORE-ID

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

    If I put in a sneaky little dump($this->getConfiguration()); in web/modules/contrib/graphql/src/Plugin/GraphQL/Schema/ComposableSchema.php in the method getExtensions

    I get the following:

      /**
       * {@inheritdoc}
       */
      protected function getExtensions() {
    
        dump($this->getConfiguration());
    
        return array_map(function ($id) {
          return $this->extensionManager->createInstance($id);
        }, array_filter($this->getConfiguration()['extensions']));
      }
    
     array:2 [โ–ผ
      "extensions" => array:16 [โ–ผ
        0 => "graphql_compose_entity_schema_extension"
        1 => "graphql_compose_language_schema_extension"
        2 => "graphql_compose_information_schema_extension"
        3 => "graphql_compose_blocks_schema_extension"
        4 => "graphql_compose_comments_schema_extension"
        5 => "graphql_compose_edges_schema_extension"
        6 => "graphql_compose_image_style_schema_extension"
        7 => "graphql_compose_layout_builder_schema_extension"
        8 => "graphql_compose_layout_paragraphs_schema_extension"
        9 => "graphql_compose_layout_schema_extension"
        10 => "graphql_compose_menus_schema_extension"
        11 => "graphql_compose_metatags_schema_extension"
        12 => "graphql_compose_preview"
        13 => "graphql_compose_route_schema_extension"
        14 => "graphql_compose_views_schema_extension"
        15 => "example_extension"
      ]
      "enabled" => true
    ]
    

    What do you get? (Plugin IDs might vary between dev and beta4)

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

    Looks like its the schema changes.

    schema_configuration: {}
    

    Should be

    schema_configuration:
      graphql_compose:
        enabled: true
    

    I'll create an update function to check for graphql compose schemas and update that.

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

    almunnings โ†’ changed the visibility of the branch 3441242-undefined-array-key to hidden.

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

    @CedricL Please pull dev at hash, or apply patch

    https://git.drupalcode.org/project/graphql_compose/-/commit/3377d6294360...

    Let me know if that is fixed after running drush updatedb or the database updates via the Drupal UI.

    Thanks!

  • Status changed to RTBC 8 months ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium cedricl

    The patch file fixed the issue. Thanks for the fast responses.

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

    Sweet. The update will rerun next release due to a number change, but glad thatโ€™s the issue found.

    Will push up b5 now.

  • Status changed to Fixed 8 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Tagged and released

    Thanks all

  • Status changed to Fixed 8 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ
Production build 0.71.5 2024