Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { Prisma } = require('prisma-binding');
const { importSchema } = require('graphql-import');
// const typeDefs = importSchema(__dirname + '/schema/generated/prisma.graphql');
const typeDefs = importSchema(__dirname + '/schema/schema_prep.graphql');
// console.log('TCL: typeDefs', typeDefs);
const prisma = new Prisma({
// typeDefs: __dirname + '/schema/schema_prep.graphql',
typeDefs,
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET
});
module.exports = prisma;
context: req => ({
...req,
db: new Prisma({
typeDefs: 'database/schema.graphql',
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET,
debug: false, // dev, // log all GraphQL queries & mutations
}),
}),
});
context: req => ({
...req,
db: new Prisma({
typeDefs: "src/generated/prisma.graphql",
endpoint: "http://localhost:4466/node-basic/dev", // the endpoint of the Prisma DB service
secret: "mysecret123", // specified in database/prisma.yml
debug: true // log all GraphQL queryies & mutations
})
})
});
const { Prisma } = require('prisma-binding');
const prisma = new Prisma({
// typeDefs: __dirname + '/schema/schema_prep.graphql',
typeDefs: './src/schema/schema_prep.graphql',
// typeDefs: __dirname + '/schema/generated/prisma.graphql',
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET
});
module.exports = prisma;
// This file connects to the remote prisma DB and gives the ability to query it with JS
const { Prisma } = require('prisma-binding');
const endpoint = (process.env.NODE_ENV == 'production')
? process.env.PRISMA_PROD_ENDPOINT
: process.env.PRISMA_DEV_ENDPOINT;
const db = new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint,
secret: process.env.PRISMA_SECRET,
debug: false,
});
module.exports = db;
const { Prisma } = require('prisma-binding');
const db = new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma DB service (value is set in variables.env)
secret: process.env.PRISMA_SECRET, // taken from prisma/prisma.yml (value is set in .env)
debug: false, // log all GraphQL queries & mutations
});
module.exports = db;
? process.env.PROD_CLIENT_URL
: process.env.DEV_CLIENT_URL;
const serverUrl = (node_env == 'development')
? `${process.env.HOST}:${process.env.PORT}`
: process.env.PROD_SERVER_URL;
const logs = async (resolve, root, args, context, info) => {
const result = await resolve(root, args, context, info)
if (!!context.request && !!context.request.body && typeof result == 'object') {
console.log(`[${!!context.request.userId ? context.request.userId : 'unknown'}] ${context.request.body.operationName} ${JSON.stringify(context.request.body.variables)}:\n`, result)
}
return result;
}
const db = new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint,
secret: process.env.PRISMA_SECRET,
debug: (node_env == 'development')
? true
: false,
});
const server = new GraphQLServer({
typeDefs: 'src/schema.graphql',
resolvers,
resolverValidationOptions: {
requireResolversForResolveType: false,
},
context: req => ({ ...req, db }),
middlewares: [logs]
context: req => ({
...req,
prisma: new Prisma({
typeDefs: './schema.graphql',
endpoint: 'http://localhost:4466',
debug: true
})
})
});
context: req => ({
...req,
prisma: new Prisma({
typeDefs: "src/generated/prisma.graphql",
endpoint: "https://eu1.prisma.sh/chat-app/chat-app/dev"
})
})
});
import { Prisma } from 'prisma-binding'
import { fragmentReplacements } from './resolvers/index'
const prisma = new Prisma({
typeDefs: process.env.PRISMA_SCHEMA,
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET,
fragmentReplacements,
})
export { prisma as default }