Hello Team,
Can anyone help us on how to invoke a Graphql query from Adobe IO runtime environment.
Basically we are trying to build an api layer in Adobe io which acts as middle layer between magento and other consuming applications such as AEM.
Any reference invocation or Pseudo code will help.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi,
I suggest having a look at https://github.com/adobe/commerce-cif-graphql-integration-reference. This project is about exposing a GraphQL API based on the Magento schema. The schema you implement can be a subset or extensions of the Magento schema or a completely different GraphQL schema.
Markus
Hi,
I suggest having a look at https://github.com/adobe/commerce-cif-graphql-integration-reference. This project is about exposing a GraphQL API based on the Magento schema. The schema you implement can be a subset or extensions of the Magento schema or a completely different GraphQL schema.
Markus
@mhaack -
We have extended the createCustomer in our resolvers and we are trying to call the magento and get the data as part of createCustomer call and return in as a response.
Our extended createCustomer entry point in cartResolver.js :
@Nikhil-Kumar it seems to me like a javascript/Promise (miss)handling in the code. Using "return" directly won't wait for the Promise to complete. Using Promise's "resolve" is the right way to return a response.
Please also make sure that your action returns a Promise. If it doesn't return a Promise, while invoking another javascript module which uses Promises, then javascript finishes your action before the other Promise finishes, hence returning a null object.
Hoping this helps !
@Dragosche
@mhaack
We are using something like below
async customer(){
let output;
let promise = new Promise(function(resolve,reject){
try {
output = client.mutate({
mutation: `My Graphql query`,
variables
});
}
catch(err){
console.log('Error',err);
}
resolve(output);
});
let result;
try{
result = await promise;
console.log('Returned data',result);
}
catch(error){
console.log('error',error);
}
let strData = JSON.stringify(result);
let fvalue;
if(strData){
let prse = JSON.parse(strData);
fvalue = prse.data.createCustomer.customer.email;
console.log('Logged ',fvalue);
}
let obj = {
email:fvalue,
firstname:"Nikhil",
lastname:"Kumar"
}
console.log('Object ',obj);
return Promise.resolve(obj);
}
If we see the logs, data gets properly logged in order and in the last object it before returning it contains the fetched email from the magento in the object as fvalue.
Expected data in the final object when seen in logs should be :
Views
Replies
Total Likes
@Dragosche
I am returning the Promise by resolving the output that I got from Magento:
So In the step just above where I am logging the output, it shows me the output but returns null although I returned it as a Promise.
Instead if I pass any static data it resolves fine.
Views
Likes
Replies