How to get customer group id into graphql magento2
Note: Only in GraphQL
How to get customer group id into graphql magento2
Note: Only in GraphQL
Not much clear what you are looking for. If you want to get the customer group_id in customer graphql query you can directly provide the output variable as below.
{
customer {
firstname
lastname
suffix
email
group_id
}
}
Note: This only you'll get if customer is logged in in your Model Resolver file:
protected $_customerSession;
public function __construct(
\Magento\Customer\Model\Session $customerSession,
) {
$this->_customerSession = $customerSession;
}
public function getGroupId(){
if($this->_customerSession->isLoggedIn()):
$customerGroupId = $this->_customerSession->getCustomer()->getGroupId();
endif;
}
After this you can set $customerGroupId variable as a array of your module.