pageDataProvider = $pageDataProvider; } /** * @inheritdoc */ public function resolve( Field $field, $context, ResolveInfo $info, array $value = null, array $args = null ) { $pageId = $this->getPageId($args); $pageData = $this->getPageData($pageId); return $pageData; } /** * @param array $args * @return int * @throws GraphQlInputException */ private function getPageId(array $args): int { if (!isset($args['id'])) { throw new GraphQlInputException(__('"Page id should be specified')); } return (int)$args['id']; } /** * @param int $pageId * @return array * @throws GraphQlNoSuchEntityException */ private function getPageData(int $pageId): array { try { $pageData = $this->pageDataProvider->getData($pageId); } catch (NoSuchEntityException $e) { throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e); } return $pageData; } }