Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { ApolloServer, gql, makeExecutableSchema } from 'apollo-server';
import neo4j from 'neo4j-driver';
import { typeDefs, resolvers } from './movies-schema';
const schema = makeExecutableSchema({
typeDefs: augmentTypeDefs(typeDefs),
resolverValidationOptions: {
requireResolversForResolveType: false
},
resolvers
});
// Add auto-generated mutations
const augmentedSchema = augmentSchema(schema);
const driver = neo4j.driver(
process.env.NEO4J_URI || 'bolt://localhost:7687',
neo4j.auth.basic(
process.env.NEO4J_USER || 'neo4j',
process.env.NEO4J_PASSWORD || 'letmein'
)
);
const server = new ApolloServer({
schema: augmentedSchema,
// inject the request object into the context to support middleware
// inject the Neo4j driver instance to handle database call
context: ({ req }) => {
return {
driver,
req
};
_init(config) {
this._config = config;
this._encrypted = config.encrypted || defaults.neo4j.encrypted;
this._trust = config.trust || defaults.neo4j.trust;
this._driver = Neo4j.driver(
config.server_url || defaults.neo4j.neo4jUri,
Neo4j.auth.basic(config.server_user || defaults.neo4j.neo4jUser, config.server_password || defaults.neo4j.neo4jPassword),
{
encrypted: this._encrypted,
trust: this._trust
}
);
this._query = config.initial_cypher || defaults.neo4j.initialQuery;
this._container = document.getElementById(config.container_id);
}
const getDriver = (host, auth, opts, onConnectFail = () => {}) => {
const boltHost = generateBoltHost(host)
try {
const res = neo4j.driver(boltHost, auth, opts)
return res
} catch (e) {
onConnectFail(e)
return null
}
}
import { makeAugmentedSchema } from '../../src/index';
import { ApolloServer } from 'apollo-server-express';
import express from 'express';
import bodyParser from 'body-parser';
import neo4j from 'neo4j-driver';
import { typeDefs, resolvers } from './movies-schema';
const schema = makeAugmentedSchema({
typeDefs,
resolvers
});
const driver = neo4j.driver(
process.env.NEO4J_URI || 'bolt://localhost:7687',
neo4j.auth.basic(
process.env.NEO4J_USER || 'neo4j',
process.env.NEO4J_PASSWORD || 'letmein'
)
);
const app = express();
app.use(bodyParser.json());
const checkErrorHeaderMiddleware = async (req, res, next) => {
req.error = req.headers['x-error'];
next();
};
app.use('*', checkErrorHeaderMiddleware);