Introduction

This document provides an introduction to using GraphQL APIs for the Fynd Platform. GraphQL provides a flexible and efficient approach to interact with our platform, enabling you to query and manipulate data in a more efficient manner.

What is GraphQL?

GraphQL is a query language for APIs and a runtime for executing those queries by using a type system you define for your data. It allows clients to request exactly the data they need, making it more efficient than traditional REST APIs. With GraphQL, you can:

  • Retrieve multiple resources in a single request.
  • Get predictable results with strongly typed schemas.
  • Easily evolve your API without breaking existing queries.

Key Features of Fynd Platform's GraphQL API

  1. Single Endpoint: Unlike REST APIs, which have multiple endpoints, GraphQL APIs have a single endpoint that you query for various data needs.
  2. Efficient Data Fetching: Request only the data you need, minimizing the amount of data transferred over the network.
  3. Strongly Typed Schema: Fynd Platform’s GraphQL API is built with a strongly typed schema, providing clear and comprehensive documentation and enabling advanced tooling and validation.
  4. Explorer: The GraphQL Explorer provides feature to play around Fynd Platform’s graphQL apis.

Getting Started

Prerequisites

Before you start using the Fynd Platform GraphQL API, ensure you have:

  • A Fynd Platform account with the necessary API access permissions.
  • Application/Sales channel on Fynd Platform
  • An application_id and token to authenticate your requests.

Accessing the API

The Fynd Platform Application GraphQL API is accessible at the following endpoint:

https://api.fynd.com/service/application/graphql

Authentication

To interact with our GraphQL application APIs, you'll need a valid Application ID and Application Token. You can find these credentials from your company's platform panel. This guide will help you to authenticate with Fynd's GraphQL application side APIs.

Requirements

  • You've registered on the Fynd Platform and have access to any sales channel in the company.

Step 1: Retrieve application credentials

You can obtain your application Id and application token from platform panel. Follow the steps outlined below to retrieve the credentials for your company

  1. Log in to your Fynd Platform account.
  2. Here, if you have access to any company you will get the screen to select a company, otherwise it will open Create Company form.
  3. Select the company from the company list, it will open the Fynd Platform Dashboard.
  4. Click on the Developers tab in the sidebar, which will open APIs & SDKs page.
  5. Now, click on the Application Token tab which will open a list of application credentials for all applications(sales channels) in the current company.
  6. Now, you can check the application credentials for your application(sales channel).

Step 2: Make authenticated requests to application-side APIs

To make authenticated requests to Fynd’s applications side APIs you need to pass the authorization header in the request

Header nameDescription
AuthorizationIt's a combination of application_id and application_token {application_id:application_token} base64 string. Pass this token as a Basic {base64TokenString} in authorization header.

Refer following shell script to convert application_id and application_token to base64TokenString

base64TokenString=$(echo -n {application_id}:{application_token} | base64)

Example: Authenticated request to application API

curl --request POST \
    --header 'content-type: application/json' \
    --header 'Authorization: Bearer {base64TokenString}' \
    --url 'https://api.fynd.com/service/application/graphql' \
    --data '{"query": "query AppConfig { applicationConfiguration { appDetails { id token } } }" }'

Client Libraries

Apollo Client

JavaScript/TypeScript

A comprehensive and flexible GraphQL client for JavaScript, TypeScript, React, and many other frameworks.

Relay

JavaScript/TypeScript

A JavaScript framework for building data-driven React applications with GraphQL, developed by Facebook.

gql

Python

A GraphQL client for Python with support for queries, mutations, and subscriptions.

GraphQL Java

Java

A Java implementation of GraphQL, primarily for building GraphQL servers, but it can be used as a client.

Apollo iOS

Swift (iOS)

A strongly-typed, caching GraphQL client for iOS, based on Apollo.

Apollo Kotlin

Kotlin

A strongly-typed, caching GraphQL client for Kotlin multiplatform, based on Apollo.


GraphQL Explorer

The GraphQL Explorer is a powerful, interactive tool that allows developers and users to explore, test, and query a GraphQL API with ease. It provides a user-friendly interface to interact with the GraphQL schema, construct queries and mutations, and view real-time results. This documentation will guide you through the main features and usage of the GraphQL Explorer.

Key Features

  1. Interactive Query Building: Easily construct GraphQL queries and mutations using the intuitive point-and-click interface.
  2. Schema Exploration: Browse the complete GraphQL schema, including types, fields, and documentation, directly within the explorer.
  3. Real-Time Results Execute queries and mutations and view the results instantly within the explorer.
  4. Autocomplete: Benefit from intelligent autocompletion while writing queries and mutations, reducing errors and speeding up development.
  5. History: Access and reuse previous queries and mutations using the built-in history feature.

How to Use the GraphQL Explorer

  1. Accessing the Explorer:
    1. Open the GraphQL Explorer using the following link:
  2. Exploring the Schema:
    1. Browse through the available types, queries, mutations, and subscriptions.
    2. Click on any type or field to view detailed documentation.
  3. Constructing Queries:
    1. In the main editor window, start typing your query or mutation.
    2. Use the autocomplete feature to help build your query faster.
    3. Alternatively, use the point-and-click interface to construct queries by selecting fields from the schema explorer.
  4. Executing Queries:
    1. Once your query or mutation is ready, click the "Run" button (usually represented by a play icon) to execute it.
    2. View the results in the results pane below the editor.
  5. Using Variables:
    1. Define variables in the "Query Variables" pane below the main editor.
    2. Reference these variables in your query or mutation to make your requests more dynamic.
  6. Reviewing History:
    1. Access the history of your queries and mutations by clicking the "History" button.
    2. Reuse or modify previous requests as needed.

Example Query

Here is an example of a simple GraphQL query to fetch a list of products:

query Products {
    products {
        items {
            color
            item_code
            item_type
            has_variant
            uid
            attributes
            country_of_origin
            department
            description
            name
            rating
            rating_count
            slug
            tags
            type            
        }
    }
}

To run this query:

  1. Copy the query and paste it into the main editor window.
  2. Add application_id and token. (cookie is needed in cases where user information is associated)
  3. Click the "Run" button to execute the query.
  4. View the list of products in the results pane.

Making Your First Query

Here's an example of a simple GraphQL query to fetch products using curl:

curl --request POST \
    --header 'content-type: application/json' \
    --header 'Authorization: Bearer <base64 encoded application_id:token>' \
    --url 'https://api.fynd.com/service/application/graphql' \
    --data '{"query": "query Products { products { items { 
    color item_code item_type has_variant uid attributes country_of_origin 
    department description name rating rating_count slug tags type } } }"}'
The Fynd Platform GraphQL API offers a powerful and flexible way to interact with our commerce platform. Whether you are fetching data or making changes, GraphQL provides a seamless and efficient approach. We encourage you to explore the API and leverage its capabilities to enhance your applications.

Happy querying!