@shopify/cli-kit
Version:
A set of utilities, interfaces, and models that are common across all the platform features
32 lines • 1.08 kB
JavaScript
import { graphqlRequestDoc } from './graphql.js';
import { appManagementFqdn } from '../context/fqdn.js';
import Bottleneck from 'bottleneck';
// API Rate limiter
// Jobs are launched every 150ms
// Only 10 requests can be executed concurrently.
const limiter = new Bottleneck({
minTime: 150,
maxConcurrent: 10,
});
/**
* Executes an org-scoped GraphQL query against the App Management API.
* Uses typed documents.
*
* @param options - The options for the request.
* @returns The response of the query of generic type <T>.
*/
export async function webhooksRequestDoc(options) {
const api = 'Webhooks';
const fqdn = await appManagementFqdn();
const url = `https://${fqdn}/webhooks/unstable/organizations/${options.organizationId}/graphql.json`;
const result = limiter.schedule(() => graphqlRequestDoc({
query: options.query,
api,
url,
token: options.token,
variables: options.variables,
unauthorizedHandler: options.unauthorizedHandler,
}));
return result;
}
//# sourceMappingURL=webhooks.js.map