Skip to content

Commit 45c6f1d

Browse files
authored
Update for D9 Compatibility (drupal-graphql#1000)
1 parent eb1c8e4 commit 45c6f1d

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

graphql.info.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ description: 'Base module for integrating GraphQL with Drupal.'
44
package: GraphQL
55
configure: graphql.config_page
66
core: 8.x
7+
core_version_requirement: ^8 || ^9
78
dependencies:
89
- typed_data:typed_data

src/Plugin/GraphQL/DataProducer/EntityDefinition/Fields.php

+17-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\graphql\Plugin\GraphQL\DataProducer\EntityDefinition;
44

55
use Drupal\Core\Entity\ContentEntityType;
6+
use Drupal\Core\Entity\EntityFieldManager;
67
use Drupal\Core\Entity\EntityTypeInterface;
78
use Drupal\Core\Entity\EntityTypeManager;
89
use Drupal\Core\Field\BaseFieldDefinition;
@@ -47,6 +48,13 @@ class Fields extends DataProducerPluginBase implements ContainerFactoryPluginInt
4748
*/
4849
protected $entityTypeManager;
4950

51+
/**
52+
* The entity field manager service.
53+
*
54+
* @var \Drupal\Core\Entity\EntityFieldManager
55+
*/
56+
protected $entityFieldManager;
57+
5058
/**
5159
* {@inheritdoc}
5260
*
@@ -57,7 +65,8 @@ public static function create(ContainerInterface $container, array $configuratio
5765
$configuration,
5866
$plugin_id,
5967
$plugin_definition,
60-
$container->get('entity_type.manager')
68+
$container->get('entity_type.manager'),
69+
$container->get('entity_field.manager')
6170
);
6271
}
6372

@@ -72,17 +81,21 @@ public static function create(ContainerInterface $container, array $configuratio
7281
* The plugin definition array.
7382
* @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
7483
* The entity type manager service.
84+
* @param \Drupal\Core\Entity\EntityFieldManager $entity_field_manager
85+
* The entity field manager service.
7586
*
7687
* @codeCoverageIgnore
7788
*/
7889
public function __construct(
7990
array $configuration,
8091
string $plugin_id,
8192
array $plugin_definition,
82-
EntityTypeManager $entity_type_manager
93+
EntityTypeManager $entity_type_manager,
94+
EntityFieldManager $entity_field_manager
8395
) {
8496
parent::__construct($configuration, $plugin_id, $plugin_definition);
8597
$this->entityTypeManager = $entity_type_manager;
98+
$this->entityFieldManager = $entity_field_manager;
8699
}
87100

88101
/**
@@ -115,12 +128,12 @@ public function resolve(
115128
$key = $bundle_context['key'];
116129
$id = $entity_definition->id();
117130
$entity_id = $id . '.' . $id . '.' . $key;
118-
$fields = \Drupal::entityManager()->getFieldDefinitions($id, $key);
131+
$fields = $this->entityFieldManager->getFieldDefinitions($id, $key);
119132
}
120133
else {
121134
$id = $entity_definition->id();
122135
$entity_id = $id . '.' . $id . '.default';
123-
$fields = \Drupal::entityManager()->getFieldDefinitions($id, $id);
136+
$fields = $this->entityFieldManager->getFieldDefinitions($id, $id);
124137
}
125138

126139
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $form_display_context */

tests/src/Kernel/Framework/UploadMutationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testFileUpload() {
2020
schema {
2121
mutation: Mutation
2222
}
23-
23+
2424
type Mutation {
2525
store(file: Upload!): String
2626
}
@@ -31,7 +31,7 @@ public function testFileUpload() {
3131
$this->setUpSchema($schema);
3232

3333
// Create dummy file, since symfony will test if it exists..
34-
$file = file_directory_temp() . '/graphql_upload_test.txt';
34+
$file = \Drupal::service('file_system')->getTempDirectory() . '/graphql_upload_test.txt';
3535
touch($file);
3636

3737
// Mock a mutation that accepts the upload input and just returns

0 commit comments

Comments
 (0)