Skip to content

Commit fa9764f

Browse files
authored
refactor(drupal): Drop Drupal 8 support, introduce Drupal 10 compat (#1267)
1 parent 9e4f4dd commit fa9764f

24 files changed

Lines changed: 95 additions & 87 deletions

File tree

.github/workflows/testing.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
php-versions: ['7.3', '7.4', '8.0', '8.1']
1717
drupal-core: ['9.3.x']
1818
include:
19-
# Extra run to also test on latest Drupal 8 and PHP 7.2.
20-
- php-versions: '7.2'
21-
drupal-core: '8.9.x'
19+
# Extra run to also test on latest Drupal 10 and PHP 8.1.
20+
- php-versions: '8.1'
21+
drupal-core: '10.0.x'
2222
steps:
2323
- name: Checkout Drupal core
2424
uses: actions/checkout@v2
@@ -73,17 +73,18 @@ jobs:
7373
run: |
7474
composer install --no-progress --prefer-dist --optimize-autoloader
7575
composer --no-interaction run-script drupal-phpunit-upgrade
76+
composer config --no-plugins allow-plugins.phpstan/extension-installer true
7677
7778
- name: Install GraphQL dependencies
7879
run: composer --no-interaction --no-progress require \
7980
webonyx/graphql-php:^14.8 \
8081
drupal/typed_data:^1.0 \
81-
drupal/redirect:^1.6 \
8282
phpstan/phpstan:^1.4.6 \
8383
mglaman/phpstan-drupal:^1.1.2 \
8484
phpstan/phpstan-deprecation-rules:^1.0.0 \
8585
jangregor/phpstan-prophecy:^1.0.0 \
86-
phpstan/phpstan-phpunit:^1.0.0
86+
phpstan/phpstan-phpunit:^1.0.0 \
87+
phpstan/extension-installer:^1.0
8788

8889
# We install Coder separately because updating did not work in the local
8990
# Drupal vendor dir.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"homepage": "http://drupal.org/project/graphql",
66
"license": "GPL-2.0+",
77
"require": {
8-
"php": ">=7.2",
8+
"php": ">=7.3",
99
"webonyx/graphql-php": "^14.8.0"
1010
},
1111
"minimum-stability": "dev"

examples/graphql_composable/graphql_composable.info.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: GraphQL composable example
22
type: module
33
description: 'Examples for composable GraphQL schema.'
44
package: GraphQL
5-
core: 8.x
65
dependencies:
76
- graphql:graphql
87
- node:node
9-
core_version_requirement: ^8 || ^9
8+
core_version_requirement: ^9.3 || ^10

examples/graphql_composable/src/Plugin/GraphQL/DataProducer/CreateArticle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Drupal\graphql_composable\GraphQL\Response\ArticleResponse;
99
use Drupal\node\Entity\Node;
1010
use Symfony\Component\DependencyInjection\ContainerInterface;
11+
use Drupal\Core\StringTranslation\StringTranslationTrait;
1112

1213
/**
1314
* Creates a new article entity.
@@ -28,6 +29,8 @@
2829
*/
2930
class CreateArticle extends DataProducerPluginBase implements ContainerFactoryPluginInterface {
3031

32+
use StringTranslationTrait;
33+
3134
/**
3235
* The current user.
3336
*

examples/graphql_example/graphql_examples.info.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: GraphQL examples
22
type: module
33
description: 'Examples for the GraphQL module.'
44
package: GraphQL
5-
core: 8.x
65
dependencies:
76
- graphql:graphql
87
- node:node
9-
core_version_requirement: ^8 || ^9
8+
core_version_requirement: ^9.3 || ^10

graphql.info.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ type: module
33
description: 'Base module for integrating GraphQL with Drupal.'
44
package: GraphQL
55
configure: graphql.config_page
6-
core: 8.x
7-
core_version_requirement: ^8 || ^9
6+
core_version_requirement: ^9.3 || ^10
87
dependencies:
98
- typed_data:typed_data

graphql.services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ services:
159159
- '@lock'
160160
- '@config.factory'
161161
- '@renderer'
162+
- '@event_dispatcher'
162163

163164
plugin.manager.graphql.persisted_query:
164165
class: Drupal\graphql\Plugin\PersistedQueryPluginManager

phpstan.neon

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
includes:
2-
- ../../vendor/phpstan/phpstan-deprecation-rules/rules.neon
3-
- ../../vendor/mglaman/phpstan-drupal/extension.neon
4-
- ../../vendor/jangregor/phpstan-prophecy/extension.neon
5-
- ../../vendor/phpstan/phpstan-phpunit/extension.neon
6-
71
parameters:
82
# PHPStan cannot find files in this test directory automatically.
93
scanDirectories:
@@ -21,6 +15,10 @@ parameters:
2115
# Not sure we can specify generic types properly with Drupal coding standards
2216
# yet, disable for now.
2317
checkGenericClassInNonGenericObjectType: false
18+
# Exclude the RouteLoad producer because the redirect module is not D10
19+
# compatible so we are not downloading it.
20+
excludePaths:
21+
- src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php
2422
ignoreErrors:
2523
# @todo Ignore phpstan-drupal extension's rules for now, activate later.
2624
- '#\Drupal calls should be avoided in classes, use dependency injection instead#'
@@ -31,28 +29,7 @@ parameters:
3129
- "#^Access to an undefined property Drupal\\\\#"
3230
# PHPUnit deprecation warnings in Drupal 9 that we don't care about.
3331
- "#^Call to deprecated method setMethods\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\MockBuilder:#"
34-
# Other deprecations in Drupal 9 that we can't change because we want to
35-
# support Drupal 8.
36-
- "#deprecated class Symfony\\\\Component\\\\EventDispatcher\\\\Event#"
37-
- "#deprecated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent#"
3832
- "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"
39-
- "#deprecated interface Symfony\\\\Component\\\\HttpFoundation\\\\File\\\\MimeType\\\\MimeTypeGuesserInterface#"
40-
- "#^Parameter .+ of class Symfony\\\\Component\\\\HttpFoundation\\\\File\\\\UploadedFile constructor expects .+ given\\.$#"
41-
- "#^Parameter \\#1 \\$event of method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) expects object, string given\\.$#"
42-
- """
43-
#^Call to deprecated method toInt\\(\\) of class Drupal\\\\Component\\\\Utility\\\\Bytes\\:
44-
in drupal\\:9\\.1\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\\\Component\\\\Utility\\\\Bytes\\:\\:toNumber\\(\\) instead$#
45-
"""
46-
- """
47-
#^Call to deprecated function file_munge_filename\\(\\)#
48-
"""
49-
- """
50-
#^Call to deprecated function drupal_get_path\\(\\)#
51-
"""
52-
- """
53-
#^Call to deprecated function file_create_url\\(\\)#
54-
"""
55-
- "#^Call to an undefined method Drupal\\\\Tests\\\\graphql\\\\Kernel\\\\DataProducer\\\\EntityTest\\:\\:assertMatchesRegularExpression\\(\\)\\.$#"
5633
# Drupal allows object property access to custom fields, so we cannot fix
5734
# that.
5835
- "#^Property Drupal\\\\.+ \\(Drupal\\\\Core\\\\Field\\\\FieldItemListInterface\\) does not accept .+\\.$#"

src/Event/OperationEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Drupal\graphql\GraphQL\Execution\ResolveContext;
66
use GraphQL\Executor\ExecutionResult;
7-
use Symfony\Component\EventDispatcher\Event;
7+
use Drupal\Component\EventDispatcher\Event;
88

99
/**
1010
* Represents an event that is triggered before and after a GraphQL operation.

src/EventSubscriber/SubrequestSubscriber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Drupal\language\LanguageNegotiatorInterface;
99
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1010
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
11-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
11+
use Symfony\Component\HttpKernel\Event\RequestEvent;
1212
use Symfony\Component\HttpKernel\KernelEvents;
1313

1414
/**
@@ -36,10 +36,10 @@ public function __construct(LanguageManagerInterface $languageManager, Translato
3636
/**
3737
* Handle kernel request events.
3838
*
39-
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
39+
* @param \Symfony\Component\HttpKernel\Event\RequestEvent $event
4040
* The kernel event object.
4141
*/
42-
public function onKernelRequest(GetResponseEvent $event): void {
42+
public function onKernelRequest(RequestEvent $event): void {
4343
$request = $event->getRequest();
4444
if (!$request->attributes->has('_graphql_subrequest')) {
4545
return;

0 commit comments

Comments
 (0)