<commit_before>import logging
import json
import webapp2
import six

from graphql import GraphQLError, format_error as format_graphql_error

__author__ = 'ekampf'


class GraphQLHandler(webapp2.RequestHandler):
    def post(self):
        schema = self._get_schema()
        pretty = self._get_pretty()

        if not schema:
            webapp2.abort(500, detail='GraphQL Schema is missing.')

        query, operation_name, variables, pretty_override = self._get_grapl_params()
        pretty = pretty if not pretty_override else pretty_override

        result = schema.execute(query,
                                operation_name=operation_name,
                                variable_values=variables,
                                context_value=self._get_context(),
                                root_value=self._get_root_value())

        response = {}
        if result.errors:
            response['errors'] = [self.__format_error(e) for e in result.errors]

        if result.invalid:
            return self.failed_response(400, response, pretty=pretty)

        response['data'] = result.data<commit_msg>Added logs to http handler<commit_after>import logging
import json
import webapp2
import six

from graphql import GraphQLError, format_error as format_graphql_error

__author__ = 'ekampf'


class GraphQLHandler(webapp2.RequestHandler):
    def post(self):
        schema = self._get_schema()
        pretty = self._get_pretty()

        if not schema:
            webapp2.abort(500, detail='GraphQL Schema is missing.')

        query, operation_name, variables, pretty_override = self._get_grapl_params()
        pretty = pretty if not pretty_override else pretty_override

        result = schema.execute(query,
                                operation_name=operation_name,
                                variable_values=variables,
                                context_value=self._get_context(),
                                root_value=self._get_root_value())

        response = {}
        if result.errors:
            response['errors'] = [self.__format_error(e) for e in result.errors]
            logging.warn("Request had errors: %s", response)

        if result.invalid:
            logging.error("GraphQL request is invalid: %s", response)
            return self.failed_response(400, response, pretty=pretty)

        response['data'] = result.data
{'fraction_non_alphanumeric': 0.0794314381270903, 'fraction_numerical': 0.007525083612040134, 'mean_word_length': 2.225067385444744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7226720', 'n_tokens_mistral': 641, 'n_tokens_neox': 604, 'n_words': 150}