@graphql-mesh/transport-soap 0.9.0-alpha-20250222111733-ee8356e29eed9d64190177c868f050a6a5c09828 → 0.9.0-alpha-20250222123306-c4e9853f99ab809e18ab5a1ff76df14ac19b386e

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.
package/cjs/executor.js CHANGED
@@ -5,8 +5,9 @@ const fast_xml_parser_1 = require("fast-xml-parser");
5
5
  const graphql_1 = require("graphql");
6
6
  const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
7
7
  const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
8
+ const utils_1 = require("@graphql-mesh/utils");
8
9
  const executor_1 = require("@graphql-tools/executor");
9
- const utils_1 = require("@graphql-tools/utils");
10
+ const utils_2 = require("@graphql-tools/utils");
10
11
  const fetch_1 = require("@whatwg-node/fetch");
11
12
  const parseXmlOptions_js_1 = require("./parseXmlOptions.js");
12
13
  function isOriginallyListType(type) {
@@ -78,7 +79,13 @@ function prefixWithAlias({ alias, obj, resolverData, }) {
78
79
  }
79
80
  return obj;
80
81
  }
81
- function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, xmlToJSONConverter, operationHeadersFactory, }) {
82
+ function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, xmlToJSONConverter, operationHeadersFactory, logger, }) {
83
+ if (soapAnnotations.soapNamespace) {
84
+ logger.warn(`The expected 'soapNamespace' attribute is missing in SOAP directive definition.
85
+ Update the SOAP source handler, and re-generate the schema.
86
+ Falling back to 'http://www.w3.org/2003/05/soap-envelope' as SOAP Namespace.`);
87
+ soapAnnotations.soapNamespace = 'http://www.w3.org/2003/05/soap-envelope';
88
+ }
82
89
  return async function rootValueMethod(args, context, info) {
83
90
  const envelopeAttributes = {
84
91
  'xmlns:soap': soapAnnotations.soapNamespace,
@@ -134,7 +141,7 @@ function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, x
134
141
  }, context, info);
135
142
  const responseXML = await response.text();
136
143
  if (!response.ok) {
137
- return (0, utils_1.createGraphQLError)(`Upstream HTTP Error: ${response.status}`, {
144
+ return (0, utils_2.createGraphQLError)(`Upstream HTTP Error: ${response.status}`, {
138
145
  extensions: {
139
146
  code: 'DOWNSTREAM_SERVICE_ERROR',
140
147
  subgraph: soapAnnotations.subgraph,
@@ -159,7 +166,7 @@ function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, x
159
166
  return normalizeResult(responseJSON.Envelope[0].Body[0][soapAnnotations.elementName]);
160
167
  }
161
168
  catch (e) {
162
- return (0, utils_1.createGraphQLError)(`Invalid SOAP response: ${e.message}`, {
169
+ return (0, utils_2.createGraphQLError)(`Invalid SOAP response: ${e.message}`, {
163
170
  extensions: {
164
171
  subgraph: soapAnnotations.subgraph,
165
172
  request: {
@@ -180,9 +187,9 @@ function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, x
180
187
  }
181
188
  };
182
189
  }
183
- function createRootValue(schema, fetchFn, operationHeaders) {
190
+ function createRootValue(schema, fetchFn, operationHeaders, logger) {
184
191
  const rootValue = {};
185
- const rootTypes = (0, utils_1.getRootTypes)(schema);
192
+ const rootTypes = (0, utils_2.getRootTypes)(schema);
186
193
  const jsonToXMLConverter = new fast_xml_parser_1.XMLBuilder({
187
194
  attributeNamePrefix: '',
188
195
  attributesGroupName: 'attributes',
@@ -193,7 +200,7 @@ function createRootValue(schema, fetchFn, operationHeaders) {
193
200
  for (const rootType of rootTypes) {
194
201
  const rootFieldMap = rootType.getFields();
195
202
  for (const fieldName in rootFieldMap) {
196
- const fieldDirectives = (0, utils_1.getDirectiveExtensions)(rootFieldMap[fieldName]);
203
+ const fieldDirectives = (0, utils_2.getDirectiveExtensions)(rootFieldMap[fieldName]);
197
204
  const soapDirectives = fieldDirectives?.soap;
198
205
  if (!soapDirectives?.length) {
199
206
  // skip fields without @soap directive
@@ -207,17 +214,18 @@ function createRootValue(schema, fetchFn, operationHeaders) {
207
214
  jsonToXMLConverter,
208
215
  xmlToJSONConverter,
209
216
  operationHeadersFactory,
217
+ logger,
210
218
  });
211
219
  }
212
220
  }
213
221
  }
214
222
  return rootValue;
215
223
  }
216
- function createExecutorFromSchemaAST(schema, fetchFn = fetch_1.fetch, operationHeaders = {}) {
224
+ function createExecutorFromSchemaAST(schema, fetchFn = fetch_1.fetch, operationHeaders = {}, logger = new utils_1.DefaultLogger()) {
217
225
  let rootValue;
218
226
  return function soapExecutor({ document, variables, context }) {
219
227
  if (!rootValue) {
220
- rootValue = createRootValue(schema, fetchFn, operationHeaders);
228
+ rootValue = createRootValue(schema, fetchFn, operationHeaders, logger);
221
229
  }
222
230
  return (0, executor_1.normalizedExecutor)({
223
231
  schema,
package/cjs/index.js CHANGED
@@ -5,7 +5,7 @@ const executor_js_1 = require("./executor.js");
5
5
  var executor_js_2 = require("./executor.js");
6
6
  Object.defineProperty(exports, "createExecutorFromSchemaAST", { enumerable: true, get: function () { return executor_js_2.createExecutorFromSchemaAST; } });
7
7
  exports.default = {
8
- getSubgraphExecutor({ transportEntry, subgraph, fetch }) {
8
+ getSubgraphExecutor({ transportEntry, subgraph, fetch, logger }) {
9
9
  let headers;
10
10
  if (typeof transportEntry.headers === 'string') {
11
11
  headers = JSON.parse(transportEntry.headers);
@@ -13,6 +13,6 @@ exports.default = {
13
13
  if (Array.isArray(transportEntry.headers)) {
14
14
  headers = Object.fromEntries(transportEntry.headers);
15
15
  }
16
- return (0, executor_js_1.createExecutorFromSchemaAST)(subgraph, fetch, headers);
16
+ return (0, executor_js_1.createExecutorFromSchemaAST)(subgraph, fetch, headers, logger);
17
17
  },
18
18
  };
package/esm/executor.js CHANGED
@@ -2,6 +2,7 @@ import { XMLBuilder as JSONToXMLConverter, XMLParser } from 'fast-xml-parser';
2
2
  import { isListType, isNonNullType } from 'graphql';
3
3
  import { process } from '@graphql-mesh/cross-helpers';
4
4
  import { getInterpolatedHeadersFactory, stringInterpolator, } from '@graphql-mesh/string-interpolation';
5
+ import { DefaultLogger } from '@graphql-mesh/utils';
5
6
  import { normalizedExecutor } from '@graphql-tools/executor';
6
7
  import { createGraphQLError, getDirectiveExtensions, getRootTypes, } from '@graphql-tools/utils';
7
8
  import { fetch as defaultFetchFn } from '@whatwg-node/fetch';
@@ -75,7 +76,13 @@ function prefixWithAlias({ alias, obj, resolverData, }) {
75
76
  }
76
77
  return obj;
77
78
  }
78
- function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, xmlToJSONConverter, operationHeadersFactory, }) {
79
+ function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, xmlToJSONConverter, operationHeadersFactory, logger, }) {
80
+ if (soapAnnotations.soapNamespace) {
81
+ logger.warn(`The expected 'soapNamespace' attribute is missing in SOAP directive definition.
82
+ Update the SOAP source handler, and re-generate the schema.
83
+ Falling back to 'http://www.w3.org/2003/05/soap-envelope' as SOAP Namespace.`);
84
+ soapAnnotations.soapNamespace = 'http://www.w3.org/2003/05/soap-envelope';
85
+ }
79
86
  return async function rootValueMethod(args, context, info) {
80
87
  const envelopeAttributes = {
81
88
  'xmlns:soap': soapAnnotations.soapNamespace,
@@ -177,7 +184,7 @@ function createRootValueMethod({ soapAnnotations, fetchFn, jsonToXMLConverter, x
177
184
  }
178
185
  };
179
186
  }
180
- function createRootValue(schema, fetchFn, operationHeaders) {
187
+ function createRootValue(schema, fetchFn, operationHeaders, logger) {
181
188
  const rootValue = {};
182
189
  const rootTypes = getRootTypes(schema);
183
190
  const jsonToXMLConverter = new JSONToXMLConverter({
@@ -204,17 +211,18 @@ function createRootValue(schema, fetchFn, operationHeaders) {
204
211
  jsonToXMLConverter,
205
212
  xmlToJSONConverter,
206
213
  operationHeadersFactory,
214
+ logger,
207
215
  });
208
216
  }
209
217
  }
210
218
  }
211
219
  return rootValue;
212
220
  }
213
- export function createExecutorFromSchemaAST(schema, fetchFn = defaultFetchFn, operationHeaders = {}) {
221
+ export function createExecutorFromSchemaAST(schema, fetchFn = defaultFetchFn, operationHeaders = {}, logger = new DefaultLogger()) {
214
222
  let rootValue;
215
223
  return function soapExecutor({ document, variables, context }) {
216
224
  if (!rootValue) {
217
- rootValue = createRootValue(schema, fetchFn, operationHeaders);
225
+ rootValue = createRootValue(schema, fetchFn, operationHeaders, logger);
218
226
  }
219
227
  return normalizedExecutor({
220
228
  schema,
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createExecutorFromSchemaAST } from './executor.js';
2
2
  export { createExecutorFromSchemaAST } from './executor.js';
3
3
  export default {
4
- getSubgraphExecutor({ transportEntry, subgraph, fetch }) {
4
+ getSubgraphExecutor({ transportEntry, subgraph, fetch, logger }) {
5
5
  let headers;
6
6
  if (typeof transportEntry.headers === 'string') {
7
7
  headers = JSON.parse(transportEntry.headers);
@@ -9,6 +9,6 @@ export default {
9
9
  if (Array.isArray(transportEntry.headers)) {
10
10
  headers = Object.fromEntries(transportEntry.headers);
11
11
  }
12
- return createExecutorFromSchemaAST(subgraph, fetch, headers);
12
+ return createExecutorFromSchemaAST(subgraph, fetch, headers, logger);
13
13
  },
14
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/transport-soap",
3
- "version": "0.9.0-alpha-20250222111733-ee8356e29eed9d64190177c868f050a6a5c09828",
3
+ "version": "0.9.0-alpha-20250222123306-c4e9853f99ab809e18ab5a1ff76df14ac19b386e",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "*"
@@ -9,8 +9,8 @@
9
9
  "@graphql-mesh/cross-helpers": "^0.4.10",
10
10
  "@graphql-mesh/string-interpolation": "^0.5.8",
11
11
  "@graphql-mesh/transport-common": "^0.7.13",
12
- "@graphql-mesh/types": "0.103.19-alpha-20250222111733-ee8356e29eed9d64190177c868f050a6a5c09828",
13
- "@graphql-mesh/utils": "0.103.19-alpha-20250222111733-ee8356e29eed9d64190177c868f050a6a5c09828",
12
+ "@graphql-mesh/types": "0.103.19-alpha-20250222123306-c4e9853f99ab809e18ab5a1ff76df14ac19b386e",
13
+ "@graphql-mesh/utils": "0.103.19-alpha-20250222123306-c4e9853f99ab809e18ab5a1ff76df14ac19b386e",
14
14
  "@graphql-tools/executor": "^1.3.2",
15
15
  "@graphql-tools/utils": "^10.8.0",
16
16
  "@whatwg-node/fetch": "^0.10.4",
@@ -1,4 +1,4 @@
1
1
  import type { GraphQLSchema } from 'graphql';
2
- import type { MeshFetch } from '@graphql-mesh/types';
2
+ import type { Logger, MeshFetch } from '@graphql-mesh/types';
3
3
  import { type Executor } from '@graphql-tools/utils';
4
- export declare function createExecutorFromSchemaAST(schema: GraphQLSchema, fetchFn?: MeshFetch, operationHeaders?: Record<string, string>): Executor;
4
+ export declare function createExecutorFromSchemaAST(schema: GraphQLSchema, fetchFn?: MeshFetch, operationHeaders?: Record<string, string>, logger?: Logger): Executor;
@@ -1,4 +1,4 @@
1
1
  import type { GraphQLSchema } from 'graphql';
2
- import type { MeshFetch } from '@graphql-mesh/types';
2
+ import type { Logger, MeshFetch } from '@graphql-mesh/types';
3
3
  import { type Executor } from '@graphql-tools/utils';
4
- export declare function createExecutorFromSchemaAST(schema: GraphQLSchema, fetchFn?: MeshFetch, operationHeaders?: Record<string, string>): Executor;
4
+ export declare function createExecutorFromSchemaAST(schema: GraphQLSchema, fetchFn?: MeshFetch, operationHeaders?: Record<string, string>, logger?: Logger): Executor;
@@ -1,5 +1,5 @@
1
1
  export { createExecutorFromSchemaAST } from './executor.cjs';
2
2
  declare const _default: {
3
- getSubgraphExecutor({ transportEntry, subgraph, fetch }: import("@graphql-mesh/transport-common").TransportGetSubgraphExecutorOptions<Record<string, any>>): import("@graphql-mesh/transport-common").Executor;
3
+ getSubgraphExecutor({ transportEntry, subgraph, fetch, logger }: import("@graphql-mesh/transport-common").TransportGetSubgraphExecutorOptions<Record<string, any>>): import("@graphql-mesh/transport-common").Executor;
4
4
  };
5
5
  export default _default;
@@ -1,5 +1,5 @@
1
1
  export { createExecutorFromSchemaAST } from './executor.js';
2
2
  declare const _default: {
3
- getSubgraphExecutor({ transportEntry, subgraph, fetch }: import("@graphql-mesh/transport-common").TransportGetSubgraphExecutorOptions<Record<string, any>>): import("@graphql-mesh/transport-common").Executor;
3
+ getSubgraphExecutor({ transportEntry, subgraph, fetch, logger }: import("@graphql-mesh/transport-common").TransportGetSubgraphExecutorOptions<Record<string, any>>): import("@graphql-mesh/transport-common").Executor;
4
4
  };
5
5
  export default _default;