<commit_before>'use strict';

const graphql = require('graphql-server-express');
const gqlTools = require('graphql-tools');
const bodyParser = require('body-parser');
//const _ = require('lodash');

const ast = require('./ast');
const resolvers = require('./resolvers');
const typeDefs = require('./typedefs');

module.exports = function(app, options) {
    const models = app.models();
    var types = ast(models);

    let schema = gqlTools.makeExecutableSchema({
        typeDefs: typeDefs(types),
        resolvers: resolvers(models),
        resolverValidationOptions: {
            requireResolversForAllFields: false
        }
    });

    let graphiqlPath = options.graphiqlPath || '/graphiql';
    let path = options.path || '/graphql';

    app.use(path, bodyParser.json(), graphql.graphqlExpress({
        schema: schema
    }));
    app.use(graphiqlPath, graphql.graphiqlExpress({
        endpointURL: path
    }));
};<commit_msg>feat(app): Adding request to context<commit_after>'use strict';

const graphql = require('graphql-server-express');
const gqlTools = require('graphql-tools');
const bodyParser = require('body-parser');
//const _ = require('lodash');

const ast = require('./ast');
const resolvers = require('./resolvers');
const typeDefs = require('./typedefs');

module.exports = function(app, options) {
    const models = app.models();
    var types = ast(models);

    let schema = gqlTools.makeExecutableSchema({
        typeDefs: typeDefs(types),
        resolvers: resolvers(models),
        resolverValidationOptions: {
            requireResolversForAllFields: false
        }
    });

    let graphiqlPath = options.graphiqlPath || '/graphiql';
    let path = options.path || '/graphql';

    app.use(path, bodyParser.json(), graphql.graphqlExpress(req => {
        return {
            schema,
            context: req
        };
    }));
    app.use(graphiqlPath, graphql.graphiqlExpress({
        endpointURL: path
    }));
};
{'fraction_non_alphanumeric': 0.14511201629327902, 'fraction_numerical': 0.0, 'mean_word_length': 3.2440604751619873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1587180', 'n_tokens_mistral': 589, 'n_tokens_neox': 575, 'n_words': 122}