I am running Apollo lambda server for GraphQL. I want to intercept the GraphQL query/mutation from the POST request body and parse it so I can find out which query/mutation the
You can use graphql-tag :
const gql = require('graphql-tag');
const query = `
{
qQueryEndpoint {
id
}
}
`;
const obj = gql`
${query}
`;
console.log('operation', obj.definitions[0].operation);
console.log('name', obj.definitions[0].selectionSet.selections[0].name.value);
Prints out :
operation query
name qQueryEndpoint
And with your mutation :
operation mutation
name saveSomething