Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
custom_field
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
custom_field
Merge requests
!57
Add graphql sub module.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add graphql sub module.
issue/custom_field-3423901:3423901-graphql-compose-3
into
3.0.x
Overview
0
Commits
4
Pipelines
5
Changes
9
Merged
Andy Marquis
requested to merge
issue/custom_field-3423901:3423901-graphql-compose-3
into
3.0.x
8 months ago
Overview
0
Commits
4
Pipelines
5
Changes
9
Expand
Closes
#3423901
0
0
Merge request reports
Compare
3.0.x
version 4
81df84d5
8 months ago
version 3
3beec8c2
8 months ago
version 2
d9eed10b
8 months ago
version 1
4fe97416
8 months ago
3.0.x (base)
and
latest version
latest version
81df84d5
4 commits,
8 months ago
version 4
81df84d5
4 commits,
8 months ago
version 3
3beec8c2
3 commits,
8 months ago
version 2
d9eed10b
2 commits,
8 months ago
version 1
4fe97416
1 commit,
8 months ago
9 files
+
643
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
modules/custom_field_graphql/src/Plugin/GraphQLCompose/FieldType/CustomFieldEntityReference.php
0 → 100644
+
55
−
0
Options
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\custom_field_graphql\Plugin\GraphQLCompose\FieldType
;
use
Drupal\Core\Field\FieldItemInterface
;
use
Drupal\graphql\GraphQL\Execution\FieldContext
;
use
Drupal\graphql_compose
\Plugin\GraphQL\DataProducer\FieldProducerItemInterface
;
use
Drupal\graphql_compose
\Plugin\GraphQL\DataProducer\FieldProducerTrait
;
use
Drupal\graphql_compose
\Plugin\GraphQLCompose\GraphQLComposeFieldTypeBase
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* {@inheritdoc}
*
* @GraphQLComposeFieldType(
* id = "custom_field_entity_reference",
* )
*/
class
CustomFieldEntityReference
extends
GraphQLComposeFieldTypeBase
implements
FieldProducerItemInterface
{
use
FieldProducerTrait
;
/**
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected
$entityRepository
;
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
$instance
=
parent
::
create
(
$container
,
$configuration
,
$plugin_id
,
$plugin_definition
);
$instance
->
entityRepository
=
$container
->
get
(
'entity.repository'
);
return
$instance
;
}
/**
* {@inheritdoc}
*/
public
function
resolveFieldItem
(
FieldItemInterface
$item
,
FieldContext
$context
)
{
if
(
!
$item
->
entity
)
{
return
NULL
;
}
$entity
=
$item
->
entity
;
$context
->
addCacheableDependency
(
$entity
);
return
$entity
;
}
}
Loading