You are here

protected function ThunderPagesSchemaExtension::resolvePageTypes in Thunder 6.2.x

Resolves page types.

Parameters

mixed $value: The current value.

\Drupal\graphql\GraphQL\Execution\ResolveContext $context: The resolve context.

\GraphQL\Type\Definition\ResolveInfo $info: The resolve information.

Return value

string Response type.

Throws

\Exception

File

modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderPagesSchemaExtension.php, line 197

Class

ThunderPagesSchemaExtension
Schema extension for page types.

Namespace

Drupal\thunder_gqls\Plugin\GraphQL\SchemaExtension

Code

protected function resolvePageTypes($value, ResolveContext $context, ResolveInfo $info) : string {
  if ($value instanceof NodeInterface || $value instanceof TermInterface || $value instanceof UserInterface) {
    if ($value
      ->bundle() === 'page') {
      return 'BasicPage';
    }
    return $this
      ->mapBundleToSchemaName($value
      ->bundle());
  }
  throw new \Exception('Invalid page type.');
}