8SELECT - Integration Documentation
8SELECTService Status
  • 8.HX PLATFORM
  • Shop Integration
    • 8.SDK Web (JavaScript SDK)
    • Widgets
      • βž•Add more elements, like custom headline
      • πŸ‘»Hide recommendation area in case there is no content
      • πŸ”ŽAdding widgets after 8.SDK was loaded
      • πŸ—ΊοΈInternationalization
    • Shopping Cart
    • Checkout Tracking
    • Product Export
    • A/B Testing
    • Single Page Application
    • Tag Manager
    • Data Privacy / Cookies / GDPR
  • Widgets
    • 8.SIMILAR
    • 8.SET
    • 8.SET Custom
    • Touchpoints
      • Product Page
      • Cart Layer
      • Cart
      • Content Page
  • Product Export
    • Data Transfer
    • File Format
    • Base Data
      • Details and examples
    • Fashion Content Pool
      • Details and examples
    • Image Bot
  • Sandbox
    • Demo-Integration
    • Demo-Mode
  • API
    • Changelog
      • 2.0.0
      • 1.0.1
    • General
      • Introduction
      • Authentication
      • Pagination
      • Exceptions
      • GraphQL Schema
    • Examples
      • 8.SIMILAR
      • 8.SET
      • 8.SET Custom
      • Product Page - All Content
  • API Tracking
    • Changelog
    • General
      • Introduction
      • Authentication
      • Context
      • User Identification
      • Event Validation
    • Events
      • view
        • How to evaluate if view event can be sent
        • User views 8.SET content
      • interact
        • User clicks on a product within 8.SET content
        • User adds a product to their card from within 8.SET content
        • Example what is not a product interaction
      • order
Powered by GitBook
On this page
  • Authorization Error
  • Validation Error

Was this helpful?

  1. API
  2. General

Exceptions

Any errors during resolution of a GraphQL query are returned as part of the API response.

Using GraphQL's introspection capabilities in conjunction with respective tooling allows to avoid many potential errors already during development. However of course, not all failures can be prevented.

Since a complex GraphQL query can involve many separate data sources to resolve various fields, the resolution can fail partially and still succeed in the remaining parts. That's why a response can contain a list of errors in addition to a data property.

Authorization Error

Unauthorized requests cannot be resolved properly. All top-level fields in the included query will default to null and the failed resolutions be reported as part of the list of occured errors.

Let's a ssume the following query to fetch similar products:

product(id: "8S-DEMO-Polohemd-1") {
   similarProducts(first: 5) {
      edges {
        node {
          id
        }
      }
    }
  }
}

If this query would be sent in an unauthorized request (notice the missing x-api-id header):

curl --request POST \
  --url https://api.8select.io/graphql \
  --header 'Content-Type: application/json' \
  --data '{"query":"query {\n  product(id: \"8S-DEMO-Polohemd-1\") {\n    similarProducts(first: 5) {\n      edges {\n        node {\n          id\n        }\n      }\n    }\n  }\n}\n"}'

The result would list the failure:

{
  "data": {
    "product": null
  },
  "errors": [
    {
      "path": [
        "product"
      ],
      "data": null,
      "errorType": "Unauthorized",
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "Not Authorized to access product on type ProductReference"
    }
  ]
}

Validation Error

For requests with invalid queries you will get back the information about what is wrong.

Let's assume we used a wrong argument in our query, i.e. sku instead of id:

curl --request POST \
        --url https://api.8select.io/graphql \
        --header 'Content-Type: application/json' \
        --header 'x-api-id: db54750f-80fc-4818-9455-30ca233225dc' \
        --data '{"query":"query {\n  product(sku: \"8S-DEMO-Polohemd-1\") {\n    similarProducts {\n      edges {\n        node {\n          id\n        }\n      }\n    }\n  }\n}\n"}'

The result would list the failure and hint on which line something is wrong:

{
  "data": null,
  "errors": [
    {
      "path": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "Validation error of type MissingFieldArgument: Missing field argument id @ 'product'"
    },
    {
      "path": null,
      "locations": [
        {
          "line": 2,
          "column": 11,
          "sourceName": null
        }
      ],
      "message": "Validation error of type UnknownArgument: Unknown field argument sku @ 'product'"
    }
  ]
}
PreviousPaginationNextGraphQL Schema

Last updated 10 months ago

Was this helpful?