GraphQL
Overview
EasyQuote adds two read-only GraphQL queries, eqQuote and eqQuotes, declared in etc/schema.graphqls. There are no mutations. The queries return the same data as the admin REST routes GET /V1/easyquote/quote/:id and GET /V1/easyquote/quote/quotes, so they're meant for back-office integrations, not for the storefront.
Authentication
Admin or integration token only
| Caller | Result |
|---|---|
Admin token or integration token, with MageMe_EasyQuote::manage_quotes (Sales → EasyQuote → Quotes) | Allowed |
| Admin token or integration token, without that resource | Refused: "The consumer isn't authorized to access resources." |
| Customer token | Always refused: "The current customer isn't authorized." |
| No token (guest) | Refused: "The current customer isn't authorized." |
The check lives in Model/Resolver/AbstractResolver. A customer can't read even their own quotes here; use the customer REST routes for that. Integration tokens as bearer tokens need the OAuth setting described on REST API.
Operations
eqQuote
eqQuote(quote_id: Int!, addItems: Boolean = false, addAddresses: Boolean = false): EqQuote
| Argument | Type | Default | Notes |
|---|---|---|---|
quote_id | Int! | required | Entity ID, greater than 0 |
addItems | Boolean | false | Fills items |
addAddresses | Boolean | false | Fills billing_address and shipping_address, only when the quote has shipping configured |
Unknown ID: the error Unable to find quote with ID "12", with your ID. quote_id below 1: "Quote id must be greater than 0."
eqQuotes
eqQuotes(addItems: Boolean = false, addAddresses: Boolean = false, filter: String, order_id: Int): EqQuotes
| Argument | Type | Default | Notes |
|---|---|---|---|
addItems | Boolean | false | As above |
addAddresses | Boolean | false | As above |
filter | String | none | A JSON object, passed as a string: column and value, all pairs must match, % makes a LIKE match. Invalid JSON: "Incorrect filter format." |
order_id | Int | none | Only quotes linked to this Magento order. Below 1: "Order id must be greater than 0." |
Returns all matching quotes, with no paging. count is the number of returned items.
Types
| Type | Fields |
|---|---|
EqQuote | quote_id, increment_id, store_id, customer_id, customer_email, is_virtual, items_count, status, the four currency rates, base_currency_code, store_currency_code, quote_currency_code, base_grand_total, grand_total, base_subtotal, subtotal, base_shipping_amount, shipping_amount, applied_rule_ids, created_at, updated_at, reminder_date, expiry_date, proposal_expiry_date, proposal_expiry_reminder_date, follow_up_date, the is_… flags, comments, link_hash, billing_address_id, shipping_address_id, shipping_method, shipping_description, original_subtotal, discount, cc_email, items, billing_address, shipping_address |
EqQuoteItem | The quote line: IDs, product_type, sku, name, qty, prices, discounts, tax, row totals, created_at, updated_at, comment |
EqQuoteAddress | The address: name parts, company, street, city, region, postcode, country_id, telephone, shipping method, VAT fields. All fields are String. |
EqQuotes | items: [EqQuote!], count: Int! |
Some schema fields never get a value in 1.7.5, because the resolver has no data under that name:
| Field | Why it's empty |
|---|---|
EqQuote.proposal_expiry_reminder_date, EqQuote.is_proposal_expiry_reminder_sent | The data keys are proposal_expiration_reminder_date and is_proposal_expiration_reminder_sent |
EqQuoteItem.product_options_serialized | Serialized columns are left out of the item data |
EqQuote.increment_id is a String, like the column it reads, so long quote numbers, such as those of store view 3 and up, don't overflow. Before 1.7.4 the field was typed Int. A typed GraphQL client that generated an Int for it needs its types regenerated.
Errors
Errors come back in the standard GraphQL errors array. A refused customer or guest gets HTTP 403. Input errors, such as a quote_id below 1 or a bad filter, and an unknown quote ID come with HTTP 200.
| Message | Cause |
|---|---|
| "The current customer isn't authorized." | Customer or guest caller |
| "The consumer isn't authorized to access resources." | Admin or integration without manage_quotes |
| "Quote id must be greater than 0." | quote_id below 1 |
| "Incorrect filter format." | filter is not valid JSON |
| "Order id must be greater than 0." | order_id below 1 |
Unable to find quote with ID "…" | No quote with this ID |
Examples
One quote with its lines, admin or integration token:
query {
eqQuote(quote_id: 12, addItems: true) {
quote_id
status
grand_total
quote_currency_code
items { sku qty price row_total }
}
}
{
"data": {
"eqQuote": {
"quote_id": 12,
"status": "approved",
"grand_total": 150,
"quote_currency_code": "USD",
"items": [ { "sku": "24-MB01", "qty": 5, "price": 30, "row_total": 150 } ]
}
}
}
The same query with a customer token, answered with HTTP 403:
{
"errors": [ { "message": "The current customer isn't authorized.", "extensions": { "category": "graphql-authorization" } } ],
"data": { "eqQuote": null }
}
Quotes waiting for the customer's review:
query {
eqQuotes(filter: "{\"status\":\"awaiting_review\"}") {
count
items { quote_id increment_id proposal_expiry_date }
}
}
What's next
- REST API: the customer routes, for reading a customer's own quotes and adding one to the cart.
- Service contracts: change quotes from PHP, since GraphQL is read-only.