UNPKG

@atomist/automation-client

Version:
85 lines 3.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const trace = require("stack-trace"); const graphQL_1 = require("../internal/graph/graphQL"); class ParameterEnum { constructor(value) { this.value = value; } } exports.ParameterEnum = ParameterEnum; function enumValue(value) { return new ParameterEnum(value); } exports.enumValue = enumValue; /** * Prepare a GraphQL subscription string for the use with Apollo or EventHandlers. * * Subscription can be provided by the following options: * * * subscription: string containing the subscription GraphQL, or * * path: absolute or relative path to a .graphql file to load; if provided a relative * path this will resolve the relative path to an absolute given the location of * the calling script. * * name: name GraphQL subscription operation to load; this will walk up the directory * structure starting at the location of the calling script and look for a folder * called 'graphql'. Once that folder is found, the subscription named 'name' is * being looked for. * * fragmentsDir: location of fragment .graphql files * * inline: remove any unneeded whitespace and line breaks from returned GraphQL string * * variables: the variables to bind into the subscription * * operationName: name of the subscription to use in the generated GraphQL string * * @param {{subscription?: string; path?: string; name?: string; fragmentDir?: string; inline?: boolean; * variables?: {[p: string]: string | boolean | number | ParameterEnum}}} options * @returns {string} */ function subscription(optionsOrName) { const pathToCallingFunction = trace.get()[1].getFileName(); let options; // Allow passing over a single string which would be the name of subscription file if (typeof optionsOrName === "string") { options = { name: optionsOrName, }; } else { options = optionsOrName; } options.moduleDir = options.moduleDir || pathToCallingFunction; return graphQL_1.subscription(options); } exports.subscription = subscription; /** * Prepare a GraphQL ingester SDL string for the register with the automation client. * * Ingester can be provided by the following options: * * * path: absolute or relative path to a .graphql file to load; if provided a relative * path this will resolve the relative path to an absolute given the location of * the calling script. * * name: name of the .graphql file to load; this will walk up the directory structure * starting a t the location of the calling script and look for a folder called * 'graphql'. Once that folder is found, by convention name is being looked for * in the 'ingester' sub directory. * * @param {IngesterOptions | string} optionsOrName * @returns {string} */ function ingester(optionsOrName) { const pathToCallingFunction = trace.get()[1].getFileName(); let options; // Allow passing over a single string which would be the name of ingester file if (typeof optionsOrName === "string") { options = { name: optionsOrName, }; } else { options = optionsOrName; } options.moduleDir = options.moduleDir || pathToCallingFunction; return graphQL_1.ingester(options); } exports.ingester = ingester; //# sourceMappingURL=graphQL.js.map