Discounts
The Discounts endpoints allow you to retrieve, create, update, and delete information about Discounts in a database.
List all Discounts
This query allows you to retrieve a paginated list of all your Discounts. By default, a maximum of 25 Discounts are shown per page.
Arguments
- Name
query
- Type
- String!
- Description
Supported filter parameters:
order_by
order_dir
- Name
after
- Type
- String
- Description
Returns the elements that come after the specified cursor.
- Name
first
- Type
- String
- Description
Returns up to the first
n
elements from the list.
Fields
- Label
Discount!
- Description
The Discount! query type.
Request
query DiscountsQuery($first: Int, $after: String, $query: String!){
discounts(query: "order_by:id order_dir:desc", after: "WzVE4OTA5LDEe/4OTA5XQ==", first: 10){
edges{
node{
id
code
value
type
usage_limit
one_time_usage_per_customer
started_at
expired_at
active
limited_usage
usage
}
}
pageInfo{
endCursor
hasNextPage
}
}
}
Response
{
"data": {
"edges": [
{
"node": {
"id": "RGlzY291bnQ6MzQw",
"code": "test discount",
"value": 15,
"type": "percentage",
"usage_limit": 25,
"one_time_usage_per_customer": false,
"started_at": "2023-01-03 00:00:00",
"expired_at": "2023-01-24 00:00:00",
"active": true,
"limited_usage": true,
"usage": 2,
}
}
],
"pageInfo": {
"endCursor": "WzE5OTY4LDE5OTY4XQ==",
"hasNextPage": false
}
}
}
Create a Discount
This query allows you to add a new Discount.
Arguments
- Label
createDiscountMutationInput!
- Description
The InputDiscount type.
Fields
- Label
Discount!
- Description
The Discount! query type.
Request
mutation mutationName($input: createDiscountMutationInput!) {
createDiscount(node: $node){
# Discount type fields
}
}
Response
{
"data": {
"createDiscount": {
"id": "RGlzY291bnQ6MzQw",
"code": "test discount",
"value": 15,
"type": "percentage",
"usage_limit": 25
...
}
}
}
Retrieve a Discount
This query allows you to retrieve a Discount by providing their id.
Arguments
- Name
id
- Type
- ID!
- Description
The Discount id.
Fields
- Label
Discount!
- Description
The Discount! query type.
Request
query DiscountQuery($id: ID!){
node(id: $id){
... on Discount{
# Discount type fields
}
}
}
Response
{
"data": {
"node": {
"id": "RGlzY291bnQ6MzQw",
"code": "test discount",
"value": 15,
"type": "percentage",
"usage_limit": 25
...
}
}
}
Update a Discount
This query allows you to perform an update on a Discount.
Arguments
- Name
input
- Label
updateDiscountMutationInput!
- Description
The Discount input.
Fields
- Label
Discount!
- Description
The Discount! query type.
Request
mutation updateDiscountMutation($input: updateDiscountMutationInput!){
updateDiscount(input: $input){
# Discount type fields
}
}
Response
{
"data": {
"updateDiscount": {
"id": "RGlzY291bnQ6MzQw",
"code": "test discount",
"value": 15,
"type": "percentage",
"usage_limit": 25
...
}
}
}
Delete a Discount
This query allows you to delete Discounts.
Arguments
- Name
items
- Type
- [ID!]!
- Description
The Discount ids.
Fields
- Name
[ID]
- Description
List of Discount ids.
Request
mutation deleteDiscountsMutation($items: [ID!]!){
deleteDiscounts(items: $items){
# [ID] type fields
}
}
Response
{
"data": {
"deleteDiscounts": [
"UHJvZHVjdDoxNTUxMQ==",
"UHJvZHVjdFKWATUxMQ=="
]
}
}