> For the complete documentation index, see [llms.txt](https://landofcoder.gitbook.io/magento-2-customer-membership/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://landofcoder.gitbook.io/magento-2-customer-membership/graph-ql.md).

# Graph Ql

Please setup the Graph Ql extension at here:&#x20;

{% embed url="<https://github.com/landofcoder/module-customer-membership-graph-ql>" %}

Or setup via composer by run commands:

```
composer require module-customer-membership-graph-ql
php bin/magento module:enable Lof_CustomerMembershipGraphQl
php bin/magento setup:upgrade --keep-generated
php bin/magento cache:clean
```

### Example Graph QL Query

Query Membership Products:

```
{
  membershipProducts(
    filters: {}, 
    pageSize: 10, 
    currentPage: 1, 
    sort:{
      created_at: DESC
    }
  ){
    items{
      entity_id
      sku
      name
      status
      duration {
        record_id
        membership_duration
        membership_unit
        membership_price
        membership_order
        initialize
      }
      url_key
      customer_group
      featured_package
      short_description
      price
      final_price
      created_at
      store_id
    }
    total_count
  }
}
```

Query My Membership (should logged in customer account before):

```
{
myMembership{
    membership_id
    group_id
    name
    duration
    price
    expiration_date
    created_at
    status
    product_id
    item_id
    product_options
  }
}

```

Query My Membership Transaction (should logged in customer account before):

```
{
membershipTransaction(
    filters: {}, 
    pageSize: 10, 
    currentPage: 1, 
    sort:{
      created_at: DESC
    }
  ){
    items{
      	transaction_id
      	name
      	package
      	amount
       	duration
      	duration_unit
        created_at
      	product_id
        item_id
    }
    
    total_count
  }
}

```

Query Mutation Cancel Membership Request (should logged in customer account before):

```
mutation{
  cancelMembership(customer_comment: "I want cancel my membership!")
}
```
