customerDataProvider = $customerDataProvider; $this->changeSubscriptionStatus = $changeSubscriptionStatus; $this->createAccount = $createAccount; $this->setUpUserContext = $setUpUserContext; } /** * @inheritdoc */ public function resolve( Field $field, $context, ResolveInfo $info, array $value = null, array $args = null ) { if (!isset($args['input']) || !is_array($args['input']) || empty($args['input'])) { throw new GraphQlInputException(__('"input" value should be specified')); } try { $customer = $this->createAccount->execute($args); $customerId = (int)$customer->getId(); $this->setUpUserContext->execute($context, $customer); if (array_key_exists('is_subscribed', $args['input'])) { if ($args['input']['is_subscribed']) { $this->changeSubscriptionStatus->execute($customerId, true); } } $data = $this->customerDataProvider->getCustomerById($customerId); } catch (ValidatorException $e) { throw new GraphQlInputException(__($e->getMessage())); } catch (InputMismatchException $e) { throw new GraphQlInputException(__($e->getMessage())); } return ['customer' => $data]; } }