cancel
Showing results for 
Search instead for 
Did you mean: 

Graphql company query for Company USer- how to get the user id

Graphql company query for Company USer- how to get the user id

Hello all,

     I am working on Graphql api (Magento - 2.4) for B2B customers, the default company query which lists the company users does not give the id since it is deprecated. But I want to update a company user as a logged in company admin from the Client for which I need the user id . I tried using users attribute and structure attribute in the query, but unable to get the id. Could anyone help me in this ??

Screenshot from 2021-12-27 16-11-05.png

Magento Reference : 

https://devdocs.magento.com/guides/v2.4/graphql/queries/company.html 

https://devdocs.magento.com/guides/v2.4/graphql/mutations/update-company-user.html 

1 REPLY 1

Re: Graphql company query for Company USer- how to get the user id

protected $getCustomer;

public function __construct(
\Magento\CustomerGraphQl\Model\Customer\GetCustomer $getCustomer
) {
$this->getCustomer = $getCustomer;
}

public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) {
if ($context->getExtensionAttributes()->getIsCustomer()) {
$customerData = $this->getCustomer->execute($context);
$customerId = $customerData->getId();
}
}
If issue solved, Click Kudos & Accept as Solution.
LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool