MageMe EasyQuote Magento 2 Module | GraphQL
The EasyQuote GraphQL API provides a powerful interface for developers to interact with the EasyQuote module in a Magento 2 environment using GraphQL. This documentation outlines how to utilize the GraphQL endpoints to manage and retrieve quote data effectively.
Overview
GraphQL is a query language for APIs that offers a more efficient and powerful alternative to REST. It allows clients to request exactly the data they need, making it faster and more flexible.
GraphQL API Endpoints
1. Retrieve Quote by ID
- Operation:
c2qQuote
- Description: Fetches detailed information about a specific quote.
- Arguments:
quote_id
(Int!): The ID of the quote to retrieve.addItems
(Boolean): Whether to include the quote items in the response. Defaults tofalse
.
- Returns: Quote object including specified fields.
Example Query:
query {
c2qQuote(quote_id: 123, addItems: true) {
quote_id
increment_id
customer_email
grand_total
items {
sku
name
price
}
}
}
2. List Quotes with Filters
- Operation:
c2qQuotes
- Description: Retrieves a list of quotes optionally filtered by certain criteria.
- Arguments:
addItems
(Boolean): Whether to include the quote items in the response.filter
(String): JSON string for key:value pairs to filter quotes, such as by customer ID or status.order_id
(Int): Specific order ID to filter quotes.
- Returns: An array of quote objects that match the criteria.
Example Query:
query {
c2qQuotes(filter: "{\"customer_id\": \"456\"}", order_id: 789) {
items {
quote_id
status
created_at
items {
product_id
qty
}
}
count
}
}
Data Types
Quote (C2qQuote
):
- Represents a quote with various fields like
quote_id
,increment_id
,customer_id
,status
, etc. - Contains subfields like
items
which is an array ofC2qQuoteItem
objects ifaddItems
is true.
Quote Item (C2qQuoteItem
):
- Represents an item within a quote.
- Includes fields such as
product_id
,sku
,qty
,price
, and tax details.
Quotes (C2qQuotes
):
- A wrapper type that includes an array of
C2qQuote
objects and a count of total items returned.
Permissions
To use these endpoints, the API consumer must have the appropriate permissions set up in Magento under MageMe_EasyQuote::manage_quotes
.
Conclusion
The EasyQuote GraphQL API provides comprehensive access to quote management functionalities, allowing developers to perform advanced operations like retrieving, filtering, and managing quotes directly through GraphQL. This can be integrated into frontend applications to enhance user interaction with quotes, leveraging the full capabilities of Magento 2 and EasyQuote.