Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 buildAuthObj = props => {
let auth
if (props.authenticationMethod === KERBEROS) {
auth = neo4j.auth.kerberos(props.password)
} else if (
props.authenticationMethod === NATIVE ||
!props.authenticationMethod
) {
auth = neo4j.auth.basic(props.username, props.password)
} else {
auth = null
}
return auth
}
const buildAuthObj = props => {
let auth
if (props.authenticationMethod === KERBEROS) {
auth = neo4j.auth.kerberos(props.password)
} else if (
props.authenticationMethod === NATIVE ||
!props.authenticationMethod
) {
auth = neo4j.auth.basic(props.username, props.password)
} else {
auth = null
}
return auth
}
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);
const server = new ApolloServer({
function connect (urlOrOptions: string|ConnectOptions = {
url: DEFAULT_URL
}) {
let options
if (typeof urlOrOptions === 'string') {
options = { url: urlOrOptions }
} else {
options = urlOrOptions
}
const { url = DEFAULT_URL } = options
let driver
if (options.auth) {
const { username, password } = options.auth
driver = neo4j.v1.driver(url, neo4j.auth.basic(username, password))
} else {
driver = neo4j.v1.driver(url)
}
const boundOperations = {}
for (const operationName in connectionOperations) {
boundOperations[operationName] = partial(connectionOperations[operationName], [ driver ])
}
return boundOperations
}