-
-
Notifications
You must be signed in to change notification settings - Fork 549
Queries
GraphQL API queries are a way of collecting data from the GraphQL server. So the front end can serve it to the end-user.
This query can be used to display the latest product on the home page so customers are attracted to buy the new products that come on store for sale.
Query request:
query LatestProductQuery{
latestProductQuery {
name
slug
price
main_image_url
}
}
Query response:
{
"data": {
"latestProductQuery": [
{
"name": "AvoRed Bunk Bed",
"slug": "avored-bunk-bed",
"price": 82.9,
"main_image_url": "https://place-hold.it/250/d23af0&text=avored-bunk-bed"
},
{
"name": "PHP Single Mattress",
"slug": "php-single-mattress",
"price": 83.7,
"main_image_url": "https://place-hold.it/250/d4363f&text=php-single-mattress"
},
...
...
]
}
}
This query will be helpful to fetch all the categories that avored e-commerce has.
Query Request:
query CategoryAllQuery{
allCategory {
id
name
slug
description
meta_title
meta_description
created_at
updated_at
}
}
Query Response:
{
"data": {
"allCategory": [
{
"id": "3c748da3-5766-42dd-ae0c-c9dfc8a51a9c",
"name": "PHP",
"slug": "php",
"description": null,
"meta_title": null,
"meta_description": null,
"created_at": "2022-01-03 21:27:15",
"updated_at": "2022-01-03 21:27:15"
},
{
"id": "b4f8a5a5-01a6-4fd8-9903-8ff4b7fd08b1",
"name": "Laravel",
"slug": "laravel",
"description": null,
"meta_title": null,
"meta_description": null,
"created_at": "2022-01-03 21:27:15",
"updated_at": "2022-01-03 21:27:15"
},
...
...
]
}
}
This query will be helpful to fetch single category information that avored e-commerce has.
Query Request:
query GetCategory ($slug: String!){
category(slug: $slug) {
id
name
slug
description
meta_title
meta_description
created_at
updated_at
products {
id
name
}
}
}
Query Response:
{
"data": {
"category": {
"id": "ed86467f-2190-47d7-aa9a-3ed01380d2c7",
"name": "AvoRed",
"slug": "avored",
"description": null,
"meta_title": null,
"meta_description": null,
"created_at": "2022-01-03 21:27:15",
"updated_at": "2022-01-03 21:27:15",
"products": [
{
"id": "4566f776-fe68-4778-84fd-ee0f33d32845",
"name": "AvoRed Bunk Bed"
},
{
"id": "d9695819-a1d2-4234-8e25-b46307e8f58c",
"name": "AvoRed Sofa Set"
},
...
...
]
}
}
}
A payment query is used to fetch all available payment options in avored e-commerce.
Query Request: query PaymentOptionQuery{ paymentQuery { name identifier view } }
Query Response:
{
"data": {
"paymentQuery": [
{
"name": "Cash On Delivery",
"identifier": "a-cash-on-delivery",
"view": "<button\n class=\"flex items-center justify-between w-full bg-white rounded-md border-2 border-blue-500 p-4 focus:outline-none\">\n <label class=\"flex items-center\">\n <input type=\"radio\" checked class=\"form-radio h-5 w-5 text-blue-600\" />\n <span class=\"ml-2 text-sm text-gray-700\">\n Cash on Delivery\n </span>\n </label>\n <span class=\"text-gray-600 text-sm\"></span>\n</button>\n"
}
]
}
A shipping query is used to fetch all available shipping options in avored e-commerce.
Query Request: query ShippingOption { shippingQuery { name identifier view } }
Query Response:
{
"data": {
"shippingQuery": [
{
"name": "Pickup from Store",
"identifier": "pickup",
"view": "<button\n class=\"flex items-center justify-between w-full bg-white rounded-md border-2 border-blue-500 p-4 focus:outline-none\">\n <label class=\"flex items-center\">\n <input type=\"radio\" checked class=\"form-radio h-5 w-5 text-blue-600\" />\n <span class=\"ml-2 text-sm text-gray-700\">\n Pick up from store\n </span>\n </label>\n <span class=\"text-gray-600 text-sm\"></span>\n</button>\n"
}
]
}
}
This country options query is used to build a dropdown of countries that is set up on avored e-commerce backend.
Query Request:
query CountryOptionsQuery {
countryOptions {
label
value
}
}
Query Response:
{
"data": {
"countryOptions": [
{
"label": "British Indian Ocean Territory",
"value": "0019be81-56a3-48a7-9d0c-1c393c633ad0"
},
{
"label": "Botswana",
"value": "0135dfbc-51b5-4964-823c-fbad3d8f098e"
},
...
...
]
}
}
This query is to fetch all the cart items that belong to a visitor. To use this query you need to provide the header bearer token but it get the token you not can use the auth mutation without customer's email and password it will work.
Query Request:
query CartItemAllQuery {
cartItems {
visitor_id
product_id
product {
id
name
price
}
qty
}
}
Query Response:
{
"data": {
"cartItems": [
{
"visitor_id": "69b6b849-0e9e-4542-8786-24d0f981ed0a",
"product_id": "f77a90b8-ee36-4fac-bbee-edad821f3737",
"product": {
"id": "f77a90b8-ee36-4fac-bbee-edad821f3737",
"name": "AvoRed Double Bed",
"price": 54.5
},
"qty": 1
}
]
}
}
This query is providing all the address that belongs to a logged-in customer. To get the result from this query you need a customer auth token.
Query Request:
query AddressAllQuery{
allAddress {
id
type
first_name
last_name
company_name
phone
address1
address2
city
state
postcode
country_id
created_at
updated_at
}
}
Query Response:
{
"data": {
"allAddress": [
{
"id": "45f194e6-072b-48b1-8b5c-7370bf24aedc",
"type": "SHIPPING",
"first_name": "Purvesh update",
"last_name": "Patel",
"company_name": "kedeefood ltd",
"phone": "0221742345",
"address1": "20B Cleland crescent",
"address2": "Blockhouse bay",
"city": "Auckland",
"state": "auckland",
"postcode": "0600",
"country_id": "3226531b-f87c-4e91-b79d-ddf1988e24b0",
"created_at": "2022-01-06 08:13:49",
"updated_at": "2022-01-06 21:32:28"
},
...
...
]
}
}
This query is providing a single address that belongs to a logged-in customer. To get the result from this query you need a customer auth token.
Query Request:
query ($addressId : String!){
addressQuery (id: $addressId){
id
type
first_name
last_name
company_name
phone
address1
address2
state
city
postcode
country_id
created_at
updated_at
}
}
Query Response:
{
"data": {
"addressQuery": {
"id": "45f194e6-072b-48b1-8b5c-7370bf24aedc",
"type": "SHIPPING",
"first_name": "Purvesh update",
"last_name": "Patel",
"company_name": "kedeefood ltd",
"phone": "0221742345",
"address1": "20B Cleland crescent",
"address2": "Blockhouse bay",
"state": "auckland",
"city": "Auckland",
"postcode": "0600",
"country_id": "3226531b-f87c-4e91-b79d-ddf1988e24b0",
"created_at": "2022-01-06 08:13:49",
"updated_at": "2022-01-06 21:32:28"
}
}
}
This query is providing information about the logged-in customer. To get the result from this query you need a customer's auth token.
Query Request:
query GetCustomer {
customerQuery {
id
first_name
last_name
email
created_at
updated_at
}
}
Query Response:
{
"data": {
"customerQuery": {
"id": "a1cba2cf-92a6-48a3-86ab-8dfa2a1367f1",
"first_name": "Purvesh",
"last_name": "Patel",
"email": "[email protected]",
"created_at": "2022-01-05 00:03:29",
"updated_at": "2022-01-05 22:49:49"
}
}
}
This query is providing information about the logged-in customer orders which included all the orders that have customer placed with the store. To get the result from this query you need a customer's auth token.
Query Request:
query AllOrders{
allOrders {
id
shipping_option
payment_option
order_status_name
created_at
updated_at
}
}
Query Response:
{
"data": {
"allOrders": [
{
"id": "a967ab15-694f-4192-8e79-bccf953bc387",
"shipping_option": "pickup",
"payment_option": "cash-on-delivery",
"order_status_name": "Pending",
"created_at": "2022-01-07 01:46:10",
"updated_at": "2022-01-07 01:46:10"
},
...
...
]
}
}