-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(soap): auto detection of SOAP namespace, and allow to customize …
…it (#8414) * feat(soap): auto detection of SOAP namespace, and allow to customize it * Fix CI * Changeset * Fallback * Update packages/transports/soap/src/executor.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
03dd5ed
commit d9cf1d3
Showing
19 changed files
with
211 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
'@graphql-mesh/transport-soap': minor | ||
'@omnigraph/soap': minor | ||
'@graphql-mesh/soap': minor | ||
'@graphql-mesh/types': patch | ||
--- | ||
|
||
Auto detection of SOAP version to decide SOAP namespace; | ||
For SOAP 1.1, it is set to `http://schemas.xmlsoap.org/soap/envelope/` and for SOAP 1.2, it is set to `http://www.w3.org/2003/05/soap-envelope`. | ||
|
||
If you want to use a custom namespace, you can set it like below; | ||
|
||
```ts | ||
import { defineConfig } from '@graphql-mesh/compose-cli' | ||
import { loadSOAPSubgraph } from '@omnigraph/soap' | ||
|
||
export const composeConfig = defineConfig({ | ||
subgraphs: [ | ||
{ | ||
sourceHandler: loadSOAPSubgraph('CountryInfo', { | ||
source: | ||
'http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL', | ||
soapNamespace: 'http://foo.com/schemas/soap/envelope' | ||
}) | ||
} | ||
] | ||
}) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
import { basename, join } from 'path'; | ||
import { lexicographicSortSchema } from 'graphql'; | ||
import { findAndParseConfig } from '@graphql-mesh/cli'; | ||
import { getMesh } from '@graphql-mesh/runtime'; | ||
import { ProcessedConfig } from '@graphql-mesh/config'; | ||
import { getMesh, MeshInstance } from '@graphql-mesh/runtime'; | ||
import { InMemoryStoreStorageAdapter, MeshStore } from '@graphql-mesh/store'; | ||
import { printSchemaWithDirectives } from '@graphql-tools/utils'; | ||
|
||
const store = new MeshStore('soap', new InMemoryStoreStorageAdapter(), { | ||
readonly: false, | ||
validate: false, | ||
}); | ||
|
||
const config$ = findAndParseConfig({ | ||
dir: join(__dirname, '..'), | ||
store, | ||
}); | ||
const mesh$ = config$.then(config => getMesh(config)); | ||
jest.setTimeout(30000); | ||
import { inspect } from 'util'; | ||
|
||
describe('SOAP Demo', () => { | ||
let mesh: MeshInstance; | ||
let config: ProcessedConfig; | ||
beforeAll(async () => { | ||
const store = new MeshStore('soap', new InMemoryStoreStorageAdapter(), { | ||
readonly: false, | ||
validate: false, | ||
}); | ||
config = await findAndParseConfig({ | ||
dir: join(__dirname, '..'), | ||
store, | ||
}); | ||
mesh = await getMesh(config); | ||
}); | ||
it('should generate correct schema', async () => { | ||
const { schema } = await mesh$; | ||
expect(printSchemaWithDirectives(lexicographicSortSchema(schema))).toMatchSnapshot( | ||
expect(printSchemaWithDirectives(lexicographicSortSchema(mesh.schema))).toMatchSnapshot( | ||
'soap-demo-schema', | ||
); | ||
}); | ||
it('should give correct response for example queries', async () => { | ||
const { documents } = await config$; | ||
const { execute } = await mesh$; | ||
for (const source of documents) { | ||
const result = await execute(source.document); | ||
for (const source of config.documents) { | ||
if (!source.document || !source.location) { | ||
throw new Error(`Invalid document config: ${inspect(source)}`); | ||
} | ||
const result = await mesh.execute(source.document); | ||
expect(result.errors).toBeUndefined(); | ||
expect(result).toMatchSnapshot(basename(source.location) + '-soap-demo-result'); | ||
} | ||
}); | ||
afterAll(() => mesh$.then(mesh => mesh.destroy())); | ||
afterAll(() => mesh?.destroy?.()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.