<commit_before>import {
    GraphQLSchema,
    GraphQLResult,
    Document,
    parse,
    validate,
    execute,
} from 'graphql';

<<<<<<< HEAD
// TODO: maybe return a status as well,
// because for HTTP we need to return 200, 400, 405 etc.

// the annoying thing is that if we want to allow operations over GET
// then we need to parse the request before we pass it in to make sure
// it's a query and not a mutation or something else.

=======
>>>>>>> f6f25c611ef12603e46c675ec01febd356579b70
export interface GqlResponse {
    data?: Object;
    errors?: Array<string>;
}

export interface QueryOptions {
 schema: GraphQLSchema;
 query: string | Document;
 rootValue?: any;
 context?: any;
 variables?: { [key: string]: any };
 operationName?: string;
 //logFunction?: function => void
 //validationRules?: No, too risky. If you want extra validation rules, then parse it yourself.
}

function runQuery(options: QueryOptions): Promise<GraphQLResult> {
    let documentAST: Document;

    // TODO: add loggingFunction

    // if query is already an AST, don't parse or validate
    if (typeof options.query === 'string') {<commit_msg>fix merge commit<commit_after>import {
    GraphQLSchema,
    GraphQLResult,
    Document,
    parse,
    validate,
    execute,
} from 'graphql';

// TODO: maybe return a status as well,
// because for HTTP we need to return 200, 400, 405 etc.

// the annoying thing is that if we want to allow operations over GET
// then we need to parse the request before we pass it in to make sure
// it's a query and not a mutation or something else.

export interface GqlResponse {
    data?: Object;
    errors?: Array<string>;
}

export interface QueryOptions {
 schema: GraphQLSchema;
 query: string | Document;
 rootValue?: any;
 context?: any;
 variables?: { [key: string]: any };
 operationName?: string;
 //logFunction?: function => void
 //validationRules?: No, too risky. If you want extra validation rules, then parse it yourself.
}

function runQuery(options: QueryOptions): Promise<GraphQLResult> {
    let documentAST: Document;

    // TODO: add loggingFunction

    // if query is already an AST, don't parse or validate
    if (typeof options.query === 'string') {
{'fraction_non_alphanumeric': 0.10457220461747398, 'fraction_numerical': 0.019918515165233137, 'mean_word_length': 3.6041666666666665, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 16, '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': '5355364', 'n_tokens_mistral': 659, 'n_tokens_neox': 609, 'n_words': 266}