# 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!")
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://landofcoder.gitbook.io/magento-2-customer-membership/graph-ql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
