Hello Magento Friends,

Today we will learn about Magento 2: How to Get Login Customer Data in GraphQL Resolver File.

As we all know Magento 2 provides GraphQL functionalities and with the help of that our Magento database can be used by some third-party service just by API call. In Magento 2 we can directly call built-in APIs as well as we can create custom API calls as per our need and to access this APIs call, the caller needs to authenticate some APIs before API call and for that, we need some customer information for authentications.

So with the help of this blog, we are going to understand How to Get Login Customer Data in GraphQL Resolver File in our custom API call.

Let’s Do,

Steps to Get Login Customer Data in GraphQL Resolver File in Magento 2:

Step 1: First of all you need to create schema.graphqls in the below path

app\code\Vendor\Extension\etc\ 

And add below code

Step 2: Next, you need to create Getcustomerdata.php in the following path

app\code\Vendor\Extension\Model\Resolver\

And add below code

Step 3: Finally Clear Cache and Remove generated folder using the below commands.

Output:

Once you have performed the above steps successfully, you can get the customer data as follows,

Conclusion:

This way you can Get Login Customer Data in GraphQL Resolver File in Magento 2. In case of any trouble with the above code, mention it in the comment box. Make sure to spread the article within your friend circle and social media handles.

Happy Coding!

Click to rate this post!
[Total: 8 Average: 4]