You are here

public static function ComposableSchemaExampleExtension::resolveResponse in GraphQL 8.4

Resolves the response type.

Parameters

\Drupal\graphql\GraphQL\Response\ResponseInterface $response: Response object.

Return value

string Response type.

Throws

\Exception Invalid response type.

File

examples/graphql_composable/src/Plugin/GraphQL/SchemaExtension/ComposableSchemaExampleExtension.php, line 92

Class

ComposableSchemaExampleExtension
Plugin annotation @SchemaExtension( id = "composable_extension", name = "Composable Example extension", description = "A simple extension that adds node related fields.", schema = "composable" )

Namespace

Drupal\graphql_composable\Plugin\GraphQL\SchemaExtension

Code

public static function resolveResponse(ResponseInterface $response) : string {

  // Resolve content response.
  if ($response instanceof ArticleResponse) {
    return 'ArticleResponse';
  }
  throw new \Exception('Invalid response type.');
}