I need all the customer email using graphQl in magento2. Who ever registered in magento those customers email addresses. I need to get from Api. Please help for this

  • There is no such tipe of GraphQL API, as it is storefront api and works in scope of one user
    – KAndy
    Dec 21, 2023 at 5:01
  • ok thank you for the update Dec 21, 2023 at 6:51

1 Answer 1


Please add the following files to your existing module.



type Query {
    getAllCustomer: [allEmail] @resolver(class:"VendorName\\ModuleName\\Model\\Resolver\\AllEmails") @doc(description:"It returns information all customer Email query ") @cache(cacheable: false)
type allEmail @doc(description: "It returns information all customer Email query") {
    email: String




namespace VendorName\ModuleName\Model\Resolver;

use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;

class AllEmails implements ResolverInterface
    protected $_customerFactory;

    public function __construct(
        \Magento\Customer\Model\CustomerFactory $customerFactory,
    ) {
        $this->_customerFactory = $customerFactory;

    public function resolve(
        Field $field,
        ResolveInfo $info,
        array $value = null,
        array $args = null
    ) {
        return $this->_customerFactory->create()->getCollection()->addAttributeToSelect("*")->load();

Please run the following Magento commands.

php -d memory_limit=-1 bin/magento setup:upgrade
php -d memory_limit=-1 bin/magento s:s:d -f
php -d memory_limit=-1 bin/magento s:d:c
php -d memory_limit=-1 bin/magento cache:clean

Then run the query below to retrieve all customer emails.

query getAllCustomer {
  getAllCustomer {


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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