Skip to content
Purvesh edited this page Jan 8, 2022 · 13 revisions

AvoRed GraphQL API 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.

LatestProductQuery

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"
        },
        ...
        ...
      ]
   }
}

Category All Query

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"
        },
        ...
        ...
     ]
   }
}

Category Query

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"
            },
            ...
            ...
        ]
      }
  }
}

Address All Query

This query is providing all the address that belongs to a logged-in user. To get the result from this query you need a user 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"
        },
        ...
        ...
    ]
  }
}
Clone this wiki locally