Skip to main content

Items

The Item object can represent a Product, Project, Job Offer, etc in a Swapcard Event.

Object

Fetch Products

First hundred Products

This query can be used to fetch the first 100 Products and the Product Categories.

Arguments

  • eventId - This is string value of the Event Id.

Query

query EventProducts($eventId: ID!, $cursor: CursorPaginationInput!){
event(id: $eventId) {
productCategoriesV2{
totalCount
nodes {
id
name
}
}
products(cursor: $cursor) {
nodes {
clientIds
id
name
}
}
}
}

Variables

{
"eventId": "RXZlbnRfMQ==",
"cursor": {
"first": 100
}
}

Next hundred Products

This query can be used to fetch the next 100 Products.

Arguments

  • eventId - This is string value of the Event Id.

Query

query EventProducts($eventId: ID!, $cursor: CursorPaginationInput!) {
event(id: $eventId) {
products(cursor: $cursor) {
nodes {
clientIds
id
name
}
pageInfo {
hasNextPage
endCursor
}
}
}
}

Variables

{
"eventId": "RXZlbnRfMQ==",
"cursor": {
"first": 100,
"after": "INSERT_CURSOR_ID_HERE"
}
}

By Product Ids

This query can be used to fetch the Products by Product Ids.

Arguments

  • ids - The Ids of Products that need to searched. This is an array and can have multiple values separated by comma.

Query

query EventProducts($eventId: ID!, $filter: ProductFilterInput!) {
event(id: $eventId) {
products(filter: $filter) {
nodes {
clientIds
id
name
}
}
}
}

Variables

{
"eventId": "RXZlbnRfNDY1Njc4",
"filter": {
"ids":
[
"ProductID1",
"ProductID2"
]
}
}

By categories

This query can be used to fetch the Products by categories.

Arguments

  • parentCategoryIds - The Ids of categories that need to searched. This is an array and can have multiple values separated by comma.

Query

query EventProducts($eventId: ID!, $filter: ProductFilterInput!) {
event(id: $eventId) {
products(filter: $filter) {
nodes {
clientIds
id
name
}
}
}
}

Variables

{
"eventId": "RXZlbnRfNDY1Njc4",
"filter": {
"parentCategoryIds":
[
"ProductCategoryID1",
"ProductCategoryID2"
]
}
}

Create

Product Category

This mutation can be used to create an Product Category.

Arguments

  • eventId - The Id of the Event on which the Product Category needs to be created.
  • name - The name of the Product Category in the Swapcard event.

Query

mutation createProductCategory($input: CreateProductCategoryInput!) {
createProductCategoryV2(input: $input) {
errors {
code
message
}
productCategory {
id
name
}
}
}

Variables

{
"input" : {
"name":"Job Offers",
"eventId":"RXZlbnRfMQ==",
"imageUrl":"www.test.png",
"color": "blue",
"limit": 200
}
}

Product

This mutation can be used to create a Product.

Arguments

  • eventId - The Id of the Event on which the Product needs to be created.
  • categoryId - The Category Id to which the Product belongs. This needs to be already created either manually or via the mutation __Create Product Category __
  • name - The name of the Product in the Swapcard event.
  • clientId - This is a unique external id that can be assigned to each Product.
  • translations - The translations of the Product in different languages.

Query

mutation createProduct($input: CreateProductInput!) {
createProduct(input: $input) {
product {
clientIds
customFields {
... on TextField {
id
locale
value
}
}
translations {
name
language
}
description
name
updatedAt
createdAt
exhibitors {
name
}
assetsUrls
}
errors {
message
}
}
}

Variables

{
"input" : {
"clientId": "Item1Id",
"name": "swapcard item",
"categoryId":"UHJvZHVjdENhdGVnb3J5XzEwMTYzOQ==" ,
"eventId":"RXZlbnRfMQ==",
"imageUrl":"www.test.png",
"description": "This is a swapcard item",
"customFields": [{
"definitionId": "RmllbGREZWZpbml==",
"text": {"language": "fr_FR", "value": "item"}
}],
"translations": [{
"name": "swapcard item",
"language": "en_US"
}],
"exhibitorIds": ["ExhibitorId"],
"assetsUrls": ["www.asset1.com", "www.asse2.com"]
}
}

Update

Product Category

This mutation can be used to update an Product Category.

Arguments

  • productCategoryId - The Id of the Product Category that needs to be updated.

Query

mutation updateProductCategory($input: UpdateProductCategoryInput!) {
updateProductCategoryV2(input: $input) {
errors {
code
message
}
productCategory {
id
name
}
}
}

Variables

{
"input" : {
"name":"Job Offers New",
"imageUrl":"www.testnew.png",
"productCategoryId": "UHJvZHVjdENhdGVnb3J5XzEwMTY0MA=="
}
}

Product

This mutation can be used to update a Product.

Arguments

  • productId - This is a unique Product Id in Swapcard.
  • categoryId - The Category Id to which the Product belongs. This needs to be already created either manually or via the mutation __Create Product Category __

Query

mutation updateProduct($input: UpdateProductInput!) {
updateProduct(input: $input) {
errors {
code
message
}
product {
updatedAt
id
}
}
}

Variables

{
"input" : {
"productId": "UHJvZHVjdF82MTQwMjc=",
"categoryId":"UHJvZHVjdENhdGVnb3J5XzEwMTYzOQ==" ,
"exhibitorIds": ["RXhoaWJpdG9yXzY5MDUyNA=="],
"customFields": [{
"definitionId": "RmllbGREZWZpbml==",
"text": {"language": "fr_FR", "value": "Item updated"}
}]
}
}

Delete Products

This mutation can be used to delete Products.

Arguments

  • productIds - The Ids of Products that need to be deleted. This is an array and can have multiple values separated by comma.

Note

Make sure to get the right productId and you have the permission to delete the product.

Query

mutation deleteProducts($input: DeleteProductsInput!){
deleteProducts(input: $input) {
deletedProductIds
}
}

Variables

{
"input" : {
"productIds": [
"UHJvZHVjdF82MTQwMzY=",
"UHJvZHVjdG46MTQwMzY="
]
}
}

Requirements & Constraints

Below there are some aspects that can help you avoid errors:

  • Get the right productId.
  • Make sure you have the right permission to update the product and if you can update all exhibitors that are linked to the product as well.
  • A valid event and category Id.
  • Name and nameTranslation can only have maximum of 255 caracteres.
  • Description and descriptionTranslation can only have maximum of 2000 caracteres.
  • Products cannot have more than 20 linked images.
  • Valid asset urls.
  • Image URL should not be http.
  • A valid exhibitor Id in case to link to some products.