This action sends a GraphQL query or mutation (update) to Shopify.
Parameters
 
  
   | url: string | 
   API endpoint to call (optional) Defaults to /admin/api/LOWEST_SUPPORTED_VERSION/graphql.json | 
  
  
   | query: object | 
   An object containing:
   		
      	- query: string - The GraphQL query or mutation
 
      	- variables: object - Variables used in the query (optional)
 
       
    | 
  
 
Returns
Returns a Promise resolving to a GraphQL response object.
The response object contains:
- data: The requested or updated resource
 
Examples
Query the name of the shop
Basic string query using the default endpoint:
module.exports = async function(payload, actions, context) {
	const shopResult = await actions.shopify.graphql(
		{ query: 'query { shop { name } }' }
	);
	console.log('Shop name: ', shopResult.data.shop.name)
}
Query the 'createdAt' and 'description' fields of a product
Parameterized string query using the default endpoint:
module.exports = async function(payload, actions, context) {
	const qId = 'gid://shopify/Product/6705843699795';
	const qRes = await actions.shopify.graphql(
    { query: `query {
								product(id: "${qId}") {
    							createdAt, description
  					    }
              }`
    });
	console.log('Product: ', qRes);
}
Update the 'description' and 'tags' fields of a product
Parameterized string mutation with explicit endpoint:
module.exports = async function(payload, actions, context) {
	const mId = 'gid://shopify/Product/6705843699795';
	const mRes = await actions.shopify.graphql(
		'/admin/api/2025-01/graphql.json',
    { query: `mutation {
                productUpdate(input: {id: "${mId}",
                  descriptionHtml: "Modified description",
                  tags: ["modifiedProduct"]
                }) {
                  product { descriptionHtml, tags }
                }
              }`
    }
	);
	console.log('Update result: ', mRes);
}
Create a product
Mutation using query and variables with an explicit endpoint:
module.exports = async function(payload, actions, context) {
    const query = `mutation CreateProduct($input: ProductInput!) { 
      productCreate(input: $input) { 
        product { 
          id 
          title 
          
        } 
        userErrors { 
          field 
          message 
          
        } 
      } 
    }`;
    const variables = {
        input: {
            title: payload.title,
            descriptionHtml: payload.description,
            tags: payload.tags.split(',').map(tag => tag.trim()),
        }
    };
    
    const result = await actions.shopify.graphql(
      '/admin/api/2025-01/graphql.json',
      {query, variables}
    );
    
    if (result.data.productCreate.userErrors.length > 0) {
        throw new Error(`Product creation failed: ${result.data.productCreate.userErrors.map(err => err.message).join(', ')}`);
    }
};