const queries = require("../graphql-client/queries");
const logger = require("../utils/logger");

const client = require("../graphql-client/graphql-client").client;

exports.default = async (req, res) => {
  try {
    logger.log("csi-surveyID-lookup", "DEBUG", "csi", req.body.surveyId, null);
    const gql_response = await client.request(queries.QUERY_SURVEY, {
      surveyId: req.body.surveyId
    });
    res.status(200).json(gql_response);
  } catch (error) {
    logger.log("csi-surveyID-lookup", "ERROR", "csi", req.body.surveyId, error);
    res.status(400).json(error);
  }
};
