0

How to get customer group id into graphql magento2

Note: Only in GraphQL

1

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
  }
}
| improve this answer | |
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.