@graphql-mesh/compose-cli 1.2.13 → 1.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.loadGraphQLHTTPSubgraph = loadGraphQLHTTPSubgraph;
37
37
  const graphql_1 = require("graphql");
38
+ const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
38
39
  const utils_1 = require("@graphql-mesh/utils");
39
40
  const utils_2 = require("@graphql-tools/utils");
40
41
  function fixExtends(node) {
@@ -140,6 +141,11 @@ function fixExtends(node) {
140
141
  function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQueries, operationHeaders, credentials, retry, timeout, source, schemaHeaders, federation = false, transportKind = 'http', }) {
141
142
  return (ctx) => {
142
143
  let schema$;
144
+ const interpolationData = {
145
+ env: process.env,
146
+ };
147
+ const interpolatedEndpoint = string_interpolation_1.stringInterpolator.parse(endpoint, interpolationData);
148
+ const interpolatedSource = string_interpolation_1.stringInterpolator.parse(source, interpolationData);
143
149
  function handleFetchedSchema(schema) {
144
150
  return addAnnotations({
145
151
  kind: transportKind,
@@ -155,15 +161,15 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
155
161
  },
156
162
  }, schema);
157
163
  }
158
- if (source) {
164
+ if (interpolatedSource) {
159
165
  let source$;
160
- if ((0, utils_1.isUrl)(source)) {
161
- source$ = (0, utils_2.mapMaybePromise)(ctx.fetch(source, {
166
+ if ((0, utils_1.isUrl)(interpolatedSource)) {
167
+ source$ = (0, utils_2.mapMaybePromise)(ctx.fetch(interpolatedSource, {
162
168
  headers: schemaHeaders,
163
169
  }), res => res.text());
164
170
  }
165
- else if ((0, utils_2.isValidPath)(source)) {
166
- source$ = (0, utils_1.readFile)(source, {
171
+ else if ((0, utils_2.isValidPath)(interpolatedSource)) {
172
+ source$ = (0, utils_1.readFile)(interpolatedSource, {
167
173
  allowUnknownExtensions: true,
168
174
  cwd: ctx.cwd,
169
175
  fetch: ctx.fetch,
@@ -177,7 +183,7 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
177
183
  }));
178
184
  }
179
185
  else {
180
- const fetchAsRegular = () => (0, utils_2.mapMaybePromise)(ctx.fetch(endpoint, {
186
+ const fetchAsRegular = () => (0, utils_2.mapMaybePromise)(ctx.fetch(interpolatedEndpoint, {
181
187
  method: method || (useGETForQueries ? 'GET' : 'POST'),
182
188
  headers: {
183
189
  'Content-Type': 'application/json',
@@ -209,7 +215,7 @@ function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQuer
209
215
  return schema;
210
216
  });
211
217
  });
212
- const fetchAsFederation = () => (0, utils_2.mapMaybePromise)(ctx.fetch(endpoint, {
218
+ const fetchAsFederation = () => (0, utils_2.mapMaybePromise)(ctx.fetch(interpolatedEndpoint, {
213
219
  method: method || (useGETForQueries ? 'GET' : 'POST'),
214
220
  headers: {
215
221
  'Content-Type': 'application/json',
@@ -1,4 +1,5 @@
1
1
  import { buildASTSchema, buildClientSchema, DirectiveLocation, getIntrospectionQuery, getNamedType, GraphQLDirective, GraphQLList, GraphQLNonNull, GraphQLScalarType, GraphQLSchema, GraphQLString, isObjectType, Kind, parse, visit, } from 'graphql';
2
+ import { stringInterpolator } from '@graphql-mesh/string-interpolation';
2
3
  import { isUrl, readFile } from '@graphql-mesh/utils';
3
4
  import { createGraphQLError, isValidPath, mapMaybePromise, } from '@graphql-tools/utils';
4
5
  function fixExtends(node) {
@@ -104,6 +105,11 @@ function fixExtends(node) {
104
105
  export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGETForQueries, operationHeaders, credentials, retry, timeout, source, schemaHeaders, federation = false, transportKind = 'http', }) {
105
106
  return (ctx) => {
106
107
  let schema$;
108
+ const interpolationData = {
109
+ env: process.env,
110
+ };
111
+ const interpolatedEndpoint = stringInterpolator.parse(endpoint, interpolationData);
112
+ const interpolatedSource = stringInterpolator.parse(source, interpolationData);
107
113
  function handleFetchedSchema(schema) {
108
114
  return addAnnotations({
109
115
  kind: transportKind,
@@ -119,15 +125,15 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
119
125
  },
120
126
  }, schema);
121
127
  }
122
- if (source) {
128
+ if (interpolatedSource) {
123
129
  let source$;
124
- if (isUrl(source)) {
125
- source$ = mapMaybePromise(ctx.fetch(source, {
130
+ if (isUrl(interpolatedSource)) {
131
+ source$ = mapMaybePromise(ctx.fetch(interpolatedSource, {
126
132
  headers: schemaHeaders,
127
133
  }), res => res.text());
128
134
  }
129
- else if (isValidPath(source)) {
130
- source$ = readFile(source, {
135
+ else if (isValidPath(interpolatedSource)) {
136
+ source$ = readFile(interpolatedSource, {
131
137
  allowUnknownExtensions: true,
132
138
  cwd: ctx.cwd,
133
139
  fetch: ctx.fetch,
@@ -141,7 +147,7 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
141
147
  }));
142
148
  }
143
149
  else {
144
- const fetchAsRegular = () => mapMaybePromise(ctx.fetch(endpoint, {
150
+ const fetchAsRegular = () => mapMaybePromise(ctx.fetch(interpolatedEndpoint, {
145
151
  method: method || (useGETForQueries ? 'GET' : 'POST'),
146
152
  headers: {
147
153
  'Content-Type': 'application/json',
@@ -173,7 +179,7 @@ export function loadGraphQLHTTPSubgraph(subgraphName, { endpoint, method, useGET
173
179
  return schema;
174
180
  });
175
181
  });
176
- const fetchAsFederation = () => mapMaybePromise(ctx.fetch(endpoint, {
182
+ const fetchAsFederation = () => mapMaybePromise(ctx.fetch(interpolatedEndpoint, {
177
183
  method: method || (useGETForQueries ? 'GET' : 'POST'),
178
184
  headers: {
179
185
  'Content-Type': 'application/json',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/compose-cli",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
@@ -9,6 +9,7 @@
9
9
  "@commander-js/extra-typings": "^12.1.0",
10
10
  "@graphql-mesh/fusion-composition": "^0.7.12",
11
11
  "@graphql-mesh/include": "^0.2.5",
12
+ "@graphql-mesh/string-interpolation": "^0.5.7",
12
13
  "@graphql-mesh/types": "^0.103.6",
13
14
  "@graphql-mesh/utils": "^0.103.6",
14
15
  "@graphql-tools/code-file-loader": "^8.1.7",