Customer GraphQL Query in Magento to retrieve basic information of the customer entity.
Using Customer Query, You can fetch the data of the logged-in customer by adding the customer access token as Headers.
schema.graphql file for the Customer module will be defined at, vendor/magento/module-customer-graph-ql/etc/schema.graphqls
Syntax:
type Query {
    customer: Customer
}
Customer Object contains multiple attribute fields.
1.) Generate Customer Token and set it with Bearer value,
Authorization Bearer {CUSTOMER_TOKEN}
2) Customer GraphQL Query,
{
  customer {
    firstname
    middlename
    lastname
    suffix
    prefix
    gender
    date_of_birth
    taxvat
    created_at
    default_shipping
    default_billing
    email
    is_subscribed
    addresses {
      firstname
      lastname
      street
      city
      region {
        region_code
        region
      }
      postcode
      vat_id
      country_code
      telephone
      company
    }
  }
}
The output of the Customer GraphQL Query will be data of the specific customer.
{
  "data": {
    "customer": {
      "firstname": "Rakesh",
      "middlename": "B.",
      "lastname": "Jesadiya",
      "suffix": "Mr",
      "prefix": null,
      "gender": null,
      "date_of_birth": null,
      "taxvat": null,
      "created_at": "2020-10-18 22:16:12",
      "default_shipping": "2",
      "default_billing": "2",
      "email": "rakesh@jesadiya.com",
      "is_subscribed": true
      "addresses": [
        {
          "firstname": "Rakesh",
          "lastname": "Jesadiya",
          "street": [
            "Spice Street"
          ],
          "city": "cityName",
          "region": {
            "region_code": "CA",
            "region": "California"
          },
          "postcode": "45454",
          "country_code": "US",
          "telephone": "121222222",
          "company": null
        }
      ]
    }
  }
}
If any attribute value will be null, the Response GraphQL value will be null otherwise display the specific value of the attribute.
