LogoLogo
User ManualChangelogRoadmapAboutYouTube
GraphQL API
GraphQL API
  • GraphQL API
  • Overview
    • Query types
      • Stream queries
    • Error codes
    • Schema
      • Queries
      • Mutations
      • Objects
      • Interfaces
      • Scalars
      • Input objects
      • Enums
      • Unions
  • CHANGELOG
    • Changelog
    • Breaking changes
  • Guides
    • Authentication
    • Basic query tutorial
    • Batching mutations
    • Integrating data
  • Query examples
    • List of products with attributes and they values in product stream
    • Get information about specific product and specific attribute values in specific language
    • List of 100 grouped products with simple and variable products in stream
    • List of grouped products with simple and variable products AFTER some end cursor
    • List of active languages
    • List of templates with attributes
    • List of all multimedia in stream
    • List of product relations for a specific product
    • Get values of custom fields
    • Create a simple product
    • Create a grouping product
    • Create a variable product
    • Add a child product to grouping one
    • Set quantity of child product
    • Remove a child product from grouping one
    • Add a variant to variable product
    • Get products with variants, binding attributes and variants list
    • Remove a variant product from variable one
    • Multimedia create
    • Add images to the gallery attribute
    • Change the name of the multimedia
    • Set alternative value for a multimedia
    • Delete Multimedia
    • Add a file to the product
    • Get attributes list by SKU
    • Create a product and assign / modify attributes values
    • Assign the template to a product
    • Create a category
    • Get category tree by category tree code
    • Get a specific category with values of the category attribute
    • Set multiple options in multiselect attribute on specific product
  • Add option to select type attribute
Powered by GitBook
On this page
  • A simple example of integrating categories into the system from scratch:
  • A more complex example of integrating categories

Was this helpful?

Export as PDF
  1. Guides

Integrating data

Note: the following examples are based on the API Stream integration concept - if you are not yet familiar with it check an overview of the Query types to understand the approach.

A simple example of integrating categories into the system from scratch:

Fetch the first page of the Category stream

{
  categoryStream(first: 1) {
    pageInfo {
      endCursor
      hasNextPage
    }
    edges {
      node {
        code
        name {
          value
          language
        }
      }
      cursor
    }
  }
}

first parameter put on limit how many categories are fetched in one result

example response:

{
  "data": {
    "categoryStream": {
      "pageInfo": {
        "endCursor": "YXJyYXljb25uZWN0aW9uOjQ5",
        "hasNextPage": true
      },
      "edges": [
        {
          "node": {
            "code": "category_name_clothing",
            "name": [
              {
                "value": "Clothing",
                "language": "en_GB"
              },
              {
                "value": "Odzież",
                "language": "pl_PL"
              }
            ]
          },
          "cursor": "YXJyYXljb25uZWN0aW9uOjQ5"
        }
      ]
    }
  }
}

Fetch the next page of the Category stream

Since we received information that the next page exists data.categoryStream.pageInfo.hasNextPage=true we should request the next resource. The query is very similar to the previous one except we are passing the appropriate cursor with the request:

{
  categoryStream(first: 1, after: "YXJyYXljb25uZWN0aW9uOjQ5") {
    ...
}

after parameter represents the appropriate cursor that identifies a last-fetched resource. Available as either cursor field of the node or the endCursor of PageInfo object.

example response:

{
  "data": {
    "categoryStream": {
      "pageInfo": {
        "endCursor": "YXJyYXljb25uZWN0aW9uOjUw",
        "hasNextPage": false
      }
      ...
    }
  }
}

we do know that there is no next page, therefore, there is nothing to fetch at the very moment. We can retry the next request(for the retrieved cursor) with i.e., an increased interval not to waste resources.

A more complex example of integrating categories

Alternatively in some systems, we will want only to fetch the identifier of the resource using some sort of queueing system in order to distribute the consumption processes. In that case, we can just fetch our resource ID (code in the case of categories) and the PageInfo object:

{
  categoryStream(first: 1) {
    pageInfo {
      endCursor
      hasNextPage
    }
    edges {
      node {
        code
      }
    }
  }
}

and fetch it in the separate consuming process via a single resource query:

{
  category(code: "category_name_clothing") {
    name {
      value
      language
    }
    code
  }
}

The rest of the process looks the same for the paginating over the stream.

Though given above content provides an example of handling categories you can use the same approach for every other resource available via streams like products, multimedia, and attributes.

PreviousBatching mutationsNextList of products with attributes and they values in product stream

Last updated 8 months ago

Was this helpful?