Skip to content

Instantly share code, notes, and snippets.

View chr33s's full-sized avatar

chris chr33s

View GitHub Profile
@chr33s
chr33s / index.js
Created August 29, 2025 08:21 — forked from AndreaMorone/index.js
Calculate Shopify Function Query Cost
const { parse } = require('graphql/language');
/**
* Calculates the cost of a GraphQL query based on its structure.
*
* @param {string} query - The GraphQL query to calculate the cost for.
* @param {boolean} [debug=false] - If true, additional debug information will be logged.
* @return {number} The total cost of the query.
*/
function calculateQueryCost(query, debug = true) {