Invoke Graphql query from Adobe IO

Shashi_Mulugu

MVP

06-10-2020

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.

 

@mhaack @Mihai_Corlan 

View Entire Topic

Nikhil-Kumar

MVP

07-10-2020

@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.

 

get customer(){

        let output;
        return new Promise(async function(resolve,reject){
            try {
                output = await client.mutate({
                mutation: gql`mutation($email: String, $firstname: String, $lastname: String, $password: String) {
                    createCustomer(input: { email: $email, firstname: $firstname, lastname: $lastname, password: $password }) {
                        customer {
                            email
                            firstname
                            lastname
                                    }
                    }
                }
                
                    
                    `,
               variables
             });

             if(output && output.data && output.data.createCustomer && output.data.createCustomer.customer && output.data.createCustomer.customer.firstname){
                 ou = output.data.createCustomer.customer.firstname;
             }
            
             
           }
           catch(err){
               console.log('Error',err);
           }

           console.log('Output Data'output);
           resolve(output);