Skip to main content

Add extra fields to collection query using fieldsHelper

Description

​ This function is used to add extra fields to the collection query. You can refer this links for the available fields . ​

Dependencies

json-to-graphql-query package

We use this package to convert the object to graphql query. The current fields you will be getting in the fields object.

And then you can addFieldsToCollection function to add extra fields to the collection query. Example is given below. ​

Parameters

ParameterTypeDescription
fieldsObjectThis object will be merged with the existing collection query.

Sample usage

​ In this example we are adding the onlineStoreUrl field to the collection query.

Like the above you can add any fields to the collection query based on the available fields in the collection object. ​

import { fieldsHelper } from '@appmaker-xyz/shopify';

fieldsHelper.addFieldsToCollection({
fields: {
// add any fields in the required format
onlineStoreUrl: true,
},
});