1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const trace = require("stack-trace");
|
4 | const graphQL_1 = require("../internal/graph/graphQL");
|
5 | class ParameterEnum {
|
6 | constructor(value) {
|
7 | this.value = value;
|
8 | }
|
9 | }
|
10 | exports.ParameterEnum = ParameterEnum;
|
11 | function enumValue(value) {
|
12 | return new ParameterEnum(value);
|
13 | }
|
14 | exports.enumValue = enumValue;
|
15 | /**
|
16 | * Prepare a GraphQL subscription string for the use with Apollo or EventHandlers.
|
17 | *
|
18 | * Subscription can be provided by the following options:
|
19 | *
|
20 | * * subscription: string containing the subscription GraphQL, or
|
21 | * * path: absolute or relative path to a .graphql file to load; if provided a relative
|
22 | * path this will resolve the relative path to an absolute given the location of
|
23 | * the calling script.
|
24 | * * name: name GraphQL subscription operation to load; this will walk up the directory
|
25 | * structure starting at the location of the calling script and look for a folder
|
26 | * called 'graphql'. Once that folder is found, the subscription named 'name' is
|
27 | * being looked for.
|
28 | * * fragmentsDir: location of fragment .graphql files
|
29 | * * inline: remove any unneeded whitespace and line breaks from returned GraphQL string
|
30 | * * variables: the variables to bind into the subscription
|
31 | * * operationName: name of the subscription to use in the generated GraphQL string
|
32 | *
|
33 | * @param {{subscription?: string; path?: string; name?: string; fragmentDir?: string; inline?: boolean;
|
34 | * variables?: {[p: string]: string | boolean | number | ParameterEnum}}} options
|
35 | * @returns {string}
|
36 | */
|
37 | function subscription(optionsOrName) {
|
38 | const pathToCallingFunction = trace.get()[1].getFileName();
|
39 | let options;
|
40 | // Allow passing over a single string which would be the name of subscription file
|
41 | if (typeof optionsOrName === "string") {
|
42 | options = {
|
43 | name: optionsOrName,
|
44 | };
|
45 | }
|
46 | else {
|
47 | options = optionsOrName;
|
48 | }
|
49 | options.moduleDir = options.moduleDir || pathToCallingFunction;
|
50 | return graphQL_1.subscription(options);
|
51 | }
|
52 | exports.subscription = subscription;
|
53 | /**
|
54 | * Prepare a GraphQL ingester SDL string for the register with the automation client.
|
55 | *
|
56 | * Ingester can be provided by the following options:
|
57 | *
|
58 | * * path: absolute or relative path to a .graphql file to load; if provided a relative
|
59 | * path this will resolve the relative path to an absolute given the location of
|
60 | * the calling script.
|
61 | * * name: name of the .graphql file to load; this will walk up the directory structure
|
62 | * starting a t the location of the calling script and look for a folder called
|
63 | * 'graphql'. Once that folder is found, by convention name is being looked for
|
64 | * in the 'ingester' sub directory.
|
65 | *
|
66 | * @param {IngesterOptions | string} optionsOrName
|
67 | * @returns {string}
|
68 | */
|
69 | function ingester(optionsOrName) {
|
70 | const pathToCallingFunction = trace.get()[1].getFileName();
|
71 | let options;
|
72 | // Allow passing over a single string which would be the name of ingester file
|
73 | if (typeof optionsOrName === "string") {
|
74 | options = {
|
75 | name: optionsOrName,
|
76 | };
|
77 | }
|
78 | else {
|
79 | options = optionsOrName;
|
80 | }
|
81 | options.moduleDir = options.moduleDir || pathToCallingFunction;
|
82 | return graphQL_1.ingester(options);
|
83 | }
|
84 | exports.ingester = ingester;
|
85 | //# sourceMappingURL=graphQL.js.map |
\ | No newline at end of file |