This document covers how to use the custom query in GraphQL and to extend GraphQL capabilities for Storefront Orchestration APIs.

Prerequisite

You need to refer to this document after completing the deployment and configuration of GraphQL.

Types of Methods Used in GraphQL

The following are the types of methods used in GraphQL:

  • Query – it is used to read or fetch data. It is similar to the GET calls in the Rest API. In this document, only GraphQL query examples have been shown.
  • Mutations – it is used to change the data. It is similar to the POST calls in the REST API.

Custom Transformation

In the Infosys Equinox Commerce platform, a few code changes have been made in the .meshrc.yaml file where some nodes have been transformed like product, SKU, category (additional properties, image), and so on.

You can specify some arguments in the key section to get the desired additional properties instead of all the properties.

The following screenshot is captured from the GraphQL Playground desktop app. In the screenshot below, the first section shows all the API endpoints, the second section is where the queries are passed, and in the third section, you obtain a response.

Now, let us see how to query the properties of different APIs after transformation is performed by providing the required field values as arguments to the “key”.

Following are the sample API endpoints created on the Storefront Orchestration schema APIs:

  • getSchemaOrgCategoryByID
  • getSchemaOrgListOfProducts
  • getSchemaOrgProductByID
  • getschemaOrgProductList
  • getSchemaOrgSearch

getSchemaOrgCategoryByID

Here, you can see how you can query the API without using any key value and by selecting ONLY the additionalProperty.

Now, you may not want all the additional properties and require only a few of them. For that purpose, you need to add the specific fields and mention them in the “Key” which can be seen below marked in red. Here, you can see the response with keys: url and displaysettings.

getSchemaOrgListOfProducts

Response Without “key”

Here, you can see how you can query the API without using any key value in the additional properties.

Response With “key”

To query only with the required additional properties. For example, the key for image is altImage1,imageURL.

getSchemaOrgProductByID

To obtain responses with multiple “key” values: “altImage1,imageURL” and “Neckline,Gender,fit,Length,Fabric“.

getschemaOrgProductList

Response Without “key”

Here, you can see how you can query the API without using any key value in the additional properties.

Response With “key”

To query only with the required additional properties. For example, the key for intervalToNotifyUser,gender.

getSchemaOrgSearch

Here, you can see that all the properties are shown for this API since no argument has been passed against the “key”.

 

Revision History
2023-06-14 | JP – Page added and content uploaded.