graphql-mesh
graphql-mesh copied to clipboard
SOAP handler not working for source with authentication.
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
Make sure to fork this template and run
yarn generate
in the terminal.Please make sure Mesh package versions under
package.json
matches yours.
- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
Describe the bug We are creating a mesh with SOAP source that needs authentication to fetch the WSDL source.
We already tried on the latest version (0.94.6), but we are getting below mentioned error:
Failed to generate the schema TypeError: wsdlObject.definitions is not iterable at SOAPLoader.loadWSDL
When we are on version 0.14.25
this works but on latest version it fails. So this seems to be a bug in @omnigraph/soap
node_modules/@omnigraph/soap/cjs/SOAPLoader.js
This is how my mesh looks like:
sources:
- name: Source123
handler:
soap:
source: <MY_SOURCE>
operationHeaders:
Authorization: <MY_TOKEN>
schemaHeaders:
Authorization: <MY_TOKEN>
This is how my <MY_TOKEN> looks like: "Bearer 123abcslkdjfks234234"
To Reproduce Steps to reproduce the behavior: Provide a SOAP source that needs authentication to fetch WSDL and this fails with the error described above.
Expected behavior
SOAP source that needs authentication should also work. As it works in version 0.14.25
and not latest so this should not happen.
Environment:
- OS:
-
@graphql-mesh/...
: - NodeJS:
Additional context
Thank you for creating the issue. In order to help us reproducing it, could you give more information? For example, does it work when you send a request for WSDL on some other client such as Postman, cURL etc?
@ardatan - Thanks for reverting.
I am even not able to create the mesh. I am having .meshrc.yaml
on root and when I run yarn mesh dev
, command fails with error.
Failed to generate the schema TypeError: wsdlObject.definitions is not iterable at SOAPLoader.loadWSDL (/home/n/projects/gql-mesh-core/node_modules/@omnigraph/soap/cjs/SOAPLoader.js:406:45)
My Mesh:
sources:
- name: Source123
handler:
soap:
source: <MY_SOURCE>
operationHeaders:
Authorization: <MY_TOKEN>
schemaHeaders:
Authorization: <MY_TOKEN>
This is how my <MY_TOKEN> looks like: "Bearer 123abcslkdjfks234234"
Their is no issue with the source because if I downgrade the @graphql-mesh/soap
version to 0.14.25
it works.
The issue I think is when the source needs authentication to return WSDL resource.
This is how my projects package.json
looks like:
{
"name": "gql-mesh-core",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@graphql-mesh/cli": "^0.82.35",
"@graphql-mesh/openapi": "^0.93.2",
"@graphql-mesh/soap": "0.94.6",
"graphql": "^16.6.0"
}
}
Thanks.
Hi @ardatan , I can see that this issue has been mentioned and has been moved to project roadmap. Just wondering if you were able to reproduce the issue and is there anything I can help in, please let me know. Thanks.
Sorry unfortunately I couldn't. I still need a reproduction :(
If you can get any source endpoint that need authentication to return WSDL that will be enough to reproduce. Unfortunately I can not get any such source openly available online.
Sorry as I said I tried to reproduce it but couldn't.
Hi @ardatan , Please give this mesh a try:
sources:
- name: CommerceSource
handler:
soap:
source: https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=catalogCategoryListV1
wsdl: https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=catalogCategoryListV1
operationHeaders:
Authorization: Bearer 123456789123456789123456789
schemaHeaders:
Authorization: Bearer 123456789123456789123456789
I got this source from: https://venia.magento.com/soap/all?wsdl_list=1
Could you check if the given source has this structure? https://www.tutorialspoint.com/wsdl/wsdl_example.htm
https://github.com/Urigo/graphql-mesh/pull/5689 Could you try with the alphas in this PR? It doesn't fix the issue but it will show better error messages to understand the problem.
@ardatan - actually we can only get the WSDL resource post authorization.
So, if you directly hit this URL in chrome- https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=catalogCategoryListV1
this shows the error "The consumer isn't authorized to access %resources."
This source that I provided above I do not know the actual Bearer token for that, but I have an exact same source that works in 0.14.25 and not in 0.94.6.
Could you install the latest versions and try again?
@ardatan : I verified it against the latest version i.e. 0.94.8
and now the Authentication error that was coming in past is not coming but now we are not able to fetch data from the source (in case when authentication is needed).
So, there are two potential issues:
- For the source in which we get schema only post authentication returns
null
results. (I confirmed that the sku I am querying exists also tried with various other endpoints as well) example mesh for this case:
sources:
- name: CommerceSource
handler:
soap:
source: https://jnz3dtiuj77ca.dummycachetest.com/soap/default?wsdl&services=catalogProductRepositoryV1,catalogCategoryListV1
operationHeaders:
Authorization: Bearer 123456789123456789123456789
schemaHeaders:
Authorization: Bearer 123456789123456789123456789
- For the commerce endpoint there is all
mutation
and noquery
. [Note: this is only for commerce source] example mesh to reproduce point2:
sources:
- name: VeniaCommerceSource
handler:
soap:
source: https://jnz3dtiuj77ca.dummycachetest.com/soap/all?wsdl&services=directoryCurrencyInformationAcquirerV1
From this mesh we are only trying to get the currency information. But this is coming under mutation and not under query(same is for other endpoints as well)
mutation{
MagentoWSDL_directoryCurrencyInformationAcquirerV1Service_directoryCurrencyInformationAcquirerV1Port_directoryCurrencyInformationAcquirerV1GetCurrencyInfo{
result{
baseCurrencyCode
}
}
}