@omnigraph/soap
Version:
35 lines (34 loc) • 1.37 kB
JavaScript
import { defaultImportFn, readFileOrUrl } from '@graphql-mesh/utils';
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
import { SOAPLoader } from './SOAPLoader.js';
export * from './SOAPLoader.js';
export * from '@graphql-mesh/transport-soap';
export function loadSOAPSubgraph(subgraphName, options) {
return ({ cwd, fetch, logger }) => {
const soapLoader = new SOAPLoader({
subgraphName,
fetch,
logger,
cwd,
// Configuration from the user
schemaHeaders: options.schemaHeaders,
operationHeaders: options.operationHeaders,
endpoint: options.endpoint,
bodyAlias: options.bodyAlias,
soapHeaders: options.soapHeaders,
});
return {
name: subgraphName,
schema$: handleMaybePromise(() => readFileOrUrl(options.source, {
allowUnknownExtensions: true,
cwd,
fetch,
importFn: defaultImportFn,
logger,
}),
// Pass source as the base URL so nested <wsdl:import> / <xsd:import>
// locations resolve relative to the importing document.
wsdl => handleMaybePromise(() => soapLoader.loadWSDL(wsdl, options.source), () => soapLoader.buildSchema())),
};
};
}