You are here

public static function ScalarPluginBase::createInstance in GraphQL 8.3

Parameters

\Drupal\graphql\Plugin\SchemaBuilderInterface $builder:

\Drupal\graphql\Plugin\TypePluginManager $manager:

$definition:

$id:

Return value

mixed

Overrides TypePluginInterface::createInstance

6 methods override ScalarPluginBase::createInstance()
DateTimeIso8601::createInstance in modules/graphql_core/src/Plugin/GraphQL/Scalars/TypedData/DateTimeIso8601.php
DurationIso8601::createInstance in modules/graphql_core/src/Plugin/GraphQL/Scalars/TypedData/DurationIso8601.php
Email::createInstance in modules/graphql_core/src/Plugin/GraphQL/Scalars/TypedData/Email.php
FilterFormat::createInstance in modules/graphql_core/src/Plugin/GraphQL/Scalars/TypedData/FilterFormat.php
TimestampScalar::createInstance in src/Plugin/GraphQL/Scalars/Internal/TimestampScalar.php

... See full list

File

src/Plugin/GraphQL/Scalars/ScalarPluginBase.php, line 20

Class

ScalarPluginBase

Namespace

Drupal\graphql\Plugin\GraphQL\Scalars

Code

public static function createInstance(SchemaBuilderInterface $builder, TypePluginManager $manager, $definition, $id) {
  $callable = [
    'GraphQL\\Type\\Definition\\Type',
    strtolower($definition['name']),
  ];
  if (is_callable($callable)) {
    return $callable();
  }
  $class = get_called_class();
  return new CustomScalarType([
    'name' => $definition['name'],
    'description' => $definition['description'],
    'contexts' => $definition['contexts'],
    'serialize' => [
      $class,
      'serialize',
    ],
    'parseValue' => [
      $class,
      'parseValue',
    ],
    'parseLiteral' => [
      $class,
      'parseLiteral',
    ],
  ]);
}