diff --git a/composer.json b/composer.json index f6b13bf77baee73f62cc1e14941ec3d2ebf2f174..64393d8723f2c8b7370c6c12d37b5b7064f70fe5 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ }, "require": { "php": "^8.1", - "drupal/graphql": "^4.9", + "drupal/graphql": "5.x-dev@dev", "doctrine/inflector": "^2" }, "require-dev": { diff --git a/modules/graphql_compose_edges/src/Plugin/GraphQLCompose/SchemaType/EdgeNode.php b/modules/graphql_compose_edges/src/Plugin/GraphQLCompose/SchemaType/EdgeNode.php index dca0474c1016ef0386cfd20a816f813266387564..ef10b5a8b5c905d6458fed8b5deb658551b8baa9 100644 --- a/modules/graphql_compose_edges/src/Plugin/GraphQLCompose/SchemaType/EdgeNode.php +++ b/modules/graphql_compose_edges/src/Plugin/GraphQLCompose/SchemaType/EdgeNode.php @@ -53,6 +53,7 @@ class EdgeNode extends GraphQLComposeSchemaTypeBase { 'interfaces' => fn() => [ static::type('EdgeNode'), ], + 'fields' => fn () => [], ]); } diff --git a/src/Plugin/GraphQLCompose/SchemaType/LanguageType.php b/src/Plugin/GraphQLCompose/SchemaType/LanguageType.php index c66f9985b7113e59b1ca8abf7d44de5f3fc7743c..b932aa8aad78ec67ce0c3072ccfd6dadf819d202 100644 --- a/src/Plugin/GraphQLCompose/SchemaType/LanguageType.php +++ b/src/Plugin/GraphQLCompose/SchemaType/LanguageType.php @@ -57,14 +57,12 @@ class LanguageType extends GraphQLComposeSchemaTypeBase { $extensions[] = new ObjectType([ 'name' => 'SchemaInformation', - 'fields' => function () { - return [ - 'languages' => [ - 'type' => Type::nonNull(Type::listOf(Type::nonNull(static::type('Language')))), - 'description' => (string) $this->t('List of languages available.'), - ], - ]; - }, + 'fields' => fn () => [ + 'languages' => [ + 'type' => Type::nonNull(Type::listOf(Type::nonNull(static::type('Language')))), + 'description' => (string) $this->t('List of languages available.'), + ], + ], ]); return $extensions; diff --git a/src/Plugin/GraphQLCompose/SchemaType/SchemaInformationType.php b/src/Plugin/GraphQLCompose/SchemaType/SchemaInformationType.php index 94a498dda2c43eafcbd049d4268773cd2da3bd02..d3dd0137f1fc1865af7975a31aebe6c60169b82d 100644 --- a/src/Plugin/GraphQLCompose/SchemaType/SchemaInformationType.php +++ b/src/Plugin/GraphQLCompose/SchemaType/SchemaInformationType.php @@ -103,14 +103,12 @@ class SchemaInformationType extends GraphQLComposeSchemaTypeBase { $extensions[] = new ObjectType([ 'name' => 'Query', - 'fields' => function () { - return [ - 'info' => [ - 'type' => Type::nonNull(static::type($this->getPluginId())), - 'description' => (string) $this->t('Schema information.'), - ], - ]; - }, + 'fields' => fn () => [ + 'info' => [ + 'type' => Type::nonNull(static::type($this->getPluginId())), + 'description' => (string) $this->t('Schema information.'), + ], + ], ]); return $extensions; diff --git a/src/Plugin/GraphQLCompose/SchemaType/TranslationType.php b/src/Plugin/GraphQLCompose/SchemaType/TranslationType.php index b9db00fe647fbda8b371c9fa4dafa644bb87e0a9..d9a048f2794832a031ac8dfe68a16eaf5a325c1d 100644 --- a/src/Plugin/GraphQLCompose/SchemaType/TranslationType.php +++ b/src/Plugin/GraphQLCompose/SchemaType/TranslationType.php @@ -68,14 +68,12 @@ class TranslationType extends GraphQLComposeSchemaTypeBase { $extensions[] = new ObjectType([ 'name' => $bundle->getTypeSdl(), - 'fields' => function () { - return [ - 'translations' => [ - 'type' => Type::nonNull(Type::listOf(Type::nonNull(static::type($this->getPluginId())))), - 'description' => (string) $this->t('Available translations for content.'), - ], - ]; - }, + 'fields' => fn () => [ + 'translations' => [ + 'type' => Type::nonNull(Type::listOf(Type::nonNull(static::type($this->getPluginId())))), + 'description' => (string) $this->t('Available translations for content.'), + ], + ], ]); } } diff --git a/tests/src/Functional/Core/LayoutBuilderTest.php b/tests/src/Functional/Core/LayoutBuilderTest.php index 0b12c7e7d2649aa6786b70026f3cf0c28e15f573..3a9fef7499e21f6ee6c64738feb7a2bd64383623 100644 --- a/tests/src/Functional/Core/LayoutBuilderTest.php +++ b/tests/src/Functional/Core/LayoutBuilderTest.php @@ -644,10 +644,13 @@ class LayoutBuilderTest extends GraphQLComposeBrowserTestBase { // Swallow error. } - $this->assertStringContainsStringIgnoringCase( - '"BlockFieldNodeTestBody" not found in document', - $content['errors'][0]['message'] ?? NULL - ); + $error = $content['errors'][0]['message'] ?? NULL; + + // Check for the expected error in GraphQL 4/5. + $contains5 = stripos($error, '"BlockFieldNodeTestBody" not found in document') !== FALSE; + $contains4 = stripos($error, 'Unknown type "BlockFieldNodeTestBody"') !== FALSE; + + $this->assertTrue($contains5 || $contains4, 'Error did not meet expectations.'); $node = $content['data']['node'] ?? NULL; $body = $node['sections'][1]['components'][1] ?? NULL;