Skip to content

Commit d01c55d

Browse files
pmelabfubhy
authored andcommitted
Remaining module cleanup (#399)
1 parent 32ff4d3 commit d01c55d

125 files changed

Lines changed: 740 additions & 669 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/graphql_block/graphql_block.info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: GraphQL Block
22
type: module
33
description: 'Query Drupal blocks with GraphQL.'
44
package: GraphQL
5+
hidden: true
56
core: 8.x
67
dependencies:
78
- graphql_core

modules/graphql_block/graphql_block.module

Lines changed: 0 additions & 16 deletions
This file was deleted.

modules/graphql_breadcrumbs/graphql_breadcrumbs.info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: GraphQL Breadcrumbs
22
type: module
33
description: Expose a route's breadcrumbs to GraphQL
4+
hidden: true
45
package: GraphQL
56
core: 8.x
67
dependencies:

modules/graphql_content_mutation/graphql_content_mutation.info.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ type: module
33
description: 'Automatically create GraphQL mutations for Drupal content entities.'
44
package: GraphQL
55
core: 8.x
6+
hidden: true
67
dependencies:
78
- graphql_mutation

modules/graphql_content_mutation/src/Form/ContentEntityMutationSchemaConfigForm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ protected function getEditableConfigNames() {
8282
* {@inheritdoc}
8383
*/
8484
public function buildForm(array $form, FormStateInterface $form_state) {
85+
drupal_set_message($this->t('This form is deprecated and configuration. Settings will not be respected by the schema any more.', 'error'));
8586
$form = parent::buildForm($form, $form_state);
8687
$defaults = [];
8788
$config = $this->config('graphql_content_mutation.schema');

modules/graphql_content_mutation/src/Plugin/GraphQL/EntityCrudOutputWrapper.php renamed to modules/graphql_core/src/GraphQL/EntityCrudOutputWrapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_content_mutation\Plugin\GraphQL;
3+
namespace Drupal\graphql_core\GraphQL;
44

55
use Drupal\Core\Entity\EntityInterface;
66
use Symfony\Component\Validator\ConstraintViolationListInterface;

modules/graphql_content/src/Plugin/Deriver/EntityByIdDeriver.php renamed to modules/graphql_core/src/Plugin/Deriver/Fields/EntityByIdDeriver.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Drupal\graphql_content\Plugin\Deriver;
3+
namespace Drupal\graphql_core\Plugin\Deriver\Fields;
44

55
use Drupal\Component\Plugin\Derivative\DeriverBase;
66
use Drupal\Core\Entity\ContentEntityTypeInterface;
@@ -22,42 +22,29 @@ class EntityByIdDeriver extends DeriverBase implements ContainerDeriverInterface
2222
*/
2323
protected $entityTypeManager;
2424

25-
/**
26-
* The schema configuration service.
27-
*
28-
* @var \Drupal\graphql_content\ContentEntitySchemaConfig
29-
*/
30-
protected $schemaConfig;
31-
3225
/**
3326
* {@inheritdoc}
3427
*/
3528
public static function create(ContainerInterface $container, $basePluginId) {
3629
return new static(
37-
$container->get('entity_type.manager'),
38-
$container->get('graphql_content.schema_config')
30+
$container->get('entity_type.manager')
3931
);
4032
}
4133

4234
/**
4335
* {@inheritdoc}
4436
*/
4537
public function __construct(
46-
EntityTypeManagerInterface $entityTypeManager,
47-
ContentEntitySchemaConfig $schemaConfig
38+
EntityTypeManagerInterface $entityTypeManager
4839
) {
4940
$this->entityTypeManager = $entityTypeManager;
50-
$this->schemaConfig = $schemaConfig;
5141
}
5242

5343
/**
5444
* {@inheritdoc}
5545
*/
5646
public function getDerivativeDefinitions($basePluginDefinition) {
5747
foreach ($this->entityTypeManager->getDefinitions() as $id => $type) {
58-
if (!$this->schemaConfig->isEntityTypeExposed($id)) {
59-
continue;
60-
}
6148
if ($type instanceof ContentEntityTypeInterface) {
6249
$derivative = [
6350
'name' => StringHelper::propCase([$id, 'by', 'id']),

modules/graphql_views/src/Plugin/Deriver/ViewDeriver.php renamed to modules/graphql_core/src/Plugin/Deriver/Fields/ViewDeriver.php

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace Drupal\graphql_views\Plugin\Deriver;
3+
namespace Drupal\graphql_core\Plugin\Deriver\Fields;
44

55
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
66
use Drupal\graphql\Utility\StringHelper;
7+
use Drupal\graphql_core\Plugin\Deriver\ViewDeriverBase;
78
use Drupal\views\Plugin\views\display\DisplayPluginInterface;
8-
use Drupal\views\ViewEntityInterface;
99
use Drupal\views\Views;
1010

1111
/**
@@ -17,39 +17,41 @@ class ViewDeriver extends ViewDeriverBase implements ContainerDeriverInterface {
1717
* {@inheritdoc}
1818
*/
1919
public function getDerivativeDefinitions($basePluginDefinition) {
20-
$viewStorage = $this->entityTypeManager->getStorage('view');
21-
22-
foreach (Views::getApplicableViews('graphql_display') as list($viewId, $displayId)) {
23-
/** @var \Drupal\views\ViewEntityInterface $view */
24-
$view = $viewStorage->load($viewId);
25-
if (!$this->getRowResolveType($view, $displayId)) {
26-
continue;
20+
if ($this->entityTypeManager->hasDefinition('view')) {
21+
$viewStorage = $this->entityTypeManager->getStorage('view');
22+
23+
foreach (Views::getApplicableViews('graphql_display') as list($viewId, $displayId)) {
24+
/** @var \Drupal\views\ViewEntityInterface $view */
25+
$view = $viewStorage->load($viewId);
26+
if (!$this->getRowResolveType($view, $displayId)) {
27+
continue;
28+
}
29+
30+
/** @var \Drupal\graphql\Plugin\views\display\GraphQL $display */
31+
$display = $this->getViewDisplay($view, $displayId);
32+
33+
$id = implode('-', [$viewId, $displayId, 'view']);
34+
$info = $this->getArgumentsInfo($display->getOption('arguments') ?: []);
35+
$arguments = [];
36+
$arguments += $this->getContextualArguments($info, $id);
37+
$arguments += $this->getPagerArguments($display);
38+
$arguments += $this->getSortArguments($display, $id);
39+
$arguments += $this->getFilterArguments($display, $id);
40+
$types = $this->getTypes($info);
41+
42+
$this->derivatives[$id] = [
43+
'id' => $id,
44+
'name' => $display->getGraphQLQueryName(),
45+
'type' => $display->getGraphQLResultName(),
46+
'parents' => $types,
47+
'multi' => FALSE,
48+
'arguments' => $arguments,
49+
'view' => $viewId,
50+
'display' => $displayId,
51+
'paged' => $this->isPaged($display),
52+
'arguments_info' => $info,
53+
] + $this->getCacheMetadataDefinition($view) + $basePluginDefinition;
2754
}
28-
29-
/** @var \Drupal\graphql\Plugin\views\display\GraphQL $display */
30-
$display = $this->getViewDisplay($view, $displayId);
31-
32-
$id = implode('-', [$viewId, $displayId, 'view']);
33-
$info = $this->getArgumentsInfo($display->getOption('arguments') ?: []);
34-
$arguments = [];
35-
$arguments += $this->getContextualArguments($info, $id);
36-
$arguments += $this->getPagerArguments($display);
37-
$arguments += $this->getSortArguments($display, $id);
38-
$arguments += $this->getFilterArguments($display, $id);
39-
$types = $this->getTypes($info);
40-
41-
$this->derivatives[$id] = [
42-
'id' => $id,
43-
'name' => $display->getGraphQLQueryName(),
44-
'type' => $display->getGraphQLResultName(),
45-
'parents' => $types,
46-
'multi' => FALSE,
47-
'arguments' => $arguments,
48-
'view' => $viewId,
49-
'display' => $displayId,
50-
'paged' => $this->isPaged($display),
51-
'arguments_info' => $info,
52-
] + $this->getCacheMetadataDefinition($view) + $basePluginDefinition;
5355
}
5456

5557
return parent::getDerivativeDefinitions($basePluginDefinition);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Drupal\graphql_core\Plugin\Deriver\Fields;
4+
5+
use Drupal\graphql\Utility\StringHelper;
6+
use Drupal\graphql_core\Plugin\Deriver\ViewDeriverBase;
7+
use Drupal\views\Views;
8+
9+
/**
10+
* Derive fields from configured views.
11+
*/
12+
class ViewResultCountDeriver extends ViewDeriverBase {
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function getDerivativeDefinitions($basePluginDefinition) {
18+
if ($this->entityTypeManager->hasDefinition('view')) {
19+
$viewStorage = $this->entityTypeManager->getStorage('view');
20+
21+
foreach (Views::getApplicableViews('graphql_display') as list($viewId, $displayId)) {
22+
/** @var \Drupal\views\ViewEntityInterface $view */
23+
$view = $viewStorage->load($viewId);
24+
/** @var \Drupal\graphql\Plugin\views\display\GraphQL $display */
25+
$display = $this->getViewDisplay($view, $displayId);
26+
if (!$this->isPaged($display)) {
27+
continue;
28+
}
29+
30+
if (!$this->getRowResolveType($view, $displayId)) {
31+
continue;
32+
}
33+
34+
$id = implode('-', [$viewId, $displayId, 'result', 'count']);
35+
$this->derivatives[$id] = [
36+
'id' => $id,
37+
'type' => 'Int',
38+
'parents' => [$display->getGraphQLResultName()],
39+
'view' => $viewId,
40+
'display' => $displayId,
41+
] + $this->getCacheMetadataDefinition($view) + $basePluginDefinition;
42+
}
43+
}
44+
45+
return parent::getDerivativeDefinitions($basePluginDefinition);
46+
}
47+
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Drupal\graphql_core\Plugin\Deriver\Fields;
4+
5+
use Drupal\graphql\Utility\StringHelper;
6+
use Drupal\graphql_core\Plugin\Deriver\ViewDeriverBase;
7+
use Drupal\views\Views;
8+
9+
/**
10+
* Derive fields from configured views.
11+
*/
12+
class ViewResultListDeriver extends ViewDeriverBase {
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function getDerivativeDefinitions($basePluginDefinition) {
18+
if ($this->entityTypeManager->hasDefinition('view')) {
19+
$viewStorage = $this->entityTypeManager->getStorage('view');
20+
21+
foreach (Views::getApplicableViews('graphql_display') as list($viewId, $displayId)) {
22+
/** @var \Drupal\views\ViewEntityInterface $view */
23+
$view = $viewStorage->load($viewId);
24+
if (!$type = $this->getRowResolveType($view, $displayId)) {
25+
continue;
26+
}
27+
28+
/** @var \Drupal\graphql\Plugin\views\display\GraphQL $display */
29+
$display = $this->getViewDisplay($view, $displayId);
30+
31+
$id = implode('-', [$viewId, $displayId, 'result', 'list']);
32+
$style = $this->getViewStyle($view, $displayId);
33+
$this->derivatives[$id] = [
34+
'id' => $id,
35+
'type' => $type,
36+
'parents' => [$display->getGraphQLResultName()],
37+
'multi' => TRUE,
38+
'view' => $viewId,
39+
'display' => $displayId,
40+
'uses_fields' => $style->usesFields(),
41+
] + $this->getCacheMetadataDefinition($view) + $basePluginDefinition;
42+
}
43+
}
44+
45+
return parent::getDerivativeDefinitions($basePluginDefinition);
46+
}
47+
48+
}

0 commit comments

Comments
 (0)