Question

I am getting below data on

customer data GraphQL query

const query = () => ({
  query: 
    {
      customer {
        customer_id
        firstname
        lastname
        suffix
        email
        addresses {
          id
          firstname
          lastname
          street
          city
          default_billing
          default_shipping
          region {
            region_code
            region
          }
          postcode
          country_code
          telephone
        }
      }
    }
  
})
{
  customer: {
    id: null,
    firstname: 'User',
    lastname: 'User',
    suffix: null,
    email: 'User@user.com',
    addresses: []
  }
}

How to get customer id in this ?

Was it helpful?

Solution

In graphql id is deprecated!

When you see schema for customer, it will show id is deprecated!

enter image description here

As per file

id is not needed as part of Customer because on server side it can be identified based on customer token used for authentication. There is no need to know customer ID on the client side.

Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top