Products

The products endpoints allow you to retrieve, create, update, and delete information about products in a database.


List all products

This query allows you to retrieve a paginated list of all your products. By default, a maximum of 25 products are shown per page.

Arguments

  • Name
    query
    Type
    String!
    Description

    Supported filter parameters: order_by order_dir last_month last_week last_3_months last_year

  • 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
    Product!
    Description

    The Product query type.

Request

POST
https://api.lightfunnels.com/graphql
query productsQuery($first: Int, $after: String, $query: String!){
	products(query: "order_by:id order_dir:desc last_month", after: "WzVE4OTA5LDEe/4OTA5XQ==", first: 10){
		edges{
			node{
				id
				_id
				title
				price
				thumbnail{
					path(version: version1)
				}
				created_at
			}
			cursor
		}
		pageInfo{
			endCursor
			hasNextPage
		}
	}
}

Response

{
  "data": {
			"edges" : [
				{
					"cursor": "WzVE4OTA5LDEe/4OTA5XQ==",
					"node": {
						"id": "VzVE4OTA5LDFR4OTA5XQ==",
						"price": 10,
						"thumbnail": {
							"id": "SW1hZ2U6NTAyMTQ00",
							"path": "https://assets.lightfunnels.com/...",
							"title": "My beautiful thumbnail"
						},
						"title": "My really great product",
						"__typename": "Product",
						"_id": 14352
					}
				}		
			]
		}
}

Create a product

This query allows you to add a new product.

Arguments

Fields

  • Label
    Product!
    Description

    The Product query type.

Request

POST
https://api.lightfunnels.com/graphql
mutation mutationName($node: InputProduct!) {
	createProduct(node: $node){
		# Product type fields
	}
}

Response

{
		"data": {
			"createProduct": {
				"id": "UHJvZHVjdDoxNTg1aOA==",
				"_id": 158508,
				"title": "My product",
				"description": "My product description",
				"price": 10,
				"compare_at_price": 21,
			}
		}
	}

Retrieve a product

This query allows you to retrieve a product by providing their id.

Arguments

  • Name
    id
    Type
    Int!
    Description

    The product id.

Fields

  • Label
    Product!
    Description

    The Product query type.

Request

POST
https://api.lightfunnels.com/graphql
	query productQuery($id: Int!){
		product(id: $id){
			# Product type fields
		}
	}

Response

{
		"data": {
			"product": {
				"id": "UHJvZHVjdDoxNTUxMQ==",
				"_id": 15511,
				"title": "Awesome Demo Product",
				"description": "This is a dummy product description.",
				"notice_text": "47% Off Today Only",
				"price": 25.75,
				"compare_at_price": 39.99,
				"product_type": "physical_product",
			}
		}
	}

Update a Product

This query allows you to perform an update on a Product.

Arguments

  • Name
    id
    Type
    Int!
    Description

    The product id.

  • Name
    node
    Label
    InputUpdateProduct!
    Description

    The product node.

Fields

  • Label
    Product!
    Description

    The Product query type.

Request

Post
https://api.lightfunnels.com/graphql
mutation updateProductMutation($node: InputUpdateProduct!, $id: Int!){
		updateProduct(node: $node, id: $id){
			# Product type fields
		}
	}

Response

{
		"data": {
			"updateProduct": {
				"id": "UHJvZHVjdDoxNTUxMQ==",
				"_id": 15511,
				"title": "Awesome Demo Product",
				"description": "This is a dummy product description.",
				"notice_text": "47% Off Today Only",
				...
			}
		}
	}

Delete a Product

This query allows you to delete products.

Arguments

  • Name
    items
    Type
    [ID!]!
    Description

    The product ids.

Fields

  • Name
    [ID]
    Description

    List of product ids.

Request

POST
https://api.lightfunnels.com/graphql
	mutation deleteProductsMutation($items: [ID!]!){
		deleteProducts(items: $items){
			# [ID] type field
		}
	}

Response

{
	"data": {
		"deleteProducts": [
			"UHJvZHVjdDoxNTUxMQ==",
			"UHJvZHVjdFKWATUxMQ=="
		]
	}
}