Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function newClientStub() {
// First create the appropriate TLS certs with dgraph cert:
// $ dgraph cert
// $ dgraph cert -n localhost
// $ dgraph cert -c user
const rootCaCert = fs.readFileSync(path.join(__dirname, 'tls', 'ca.crt'));
const clientCertKey = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.key'));
const clientCert = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.crt'));
return new dgraph.DgraphClientStub(
"localhost:9080",
grpc.credentials.createSsl(rootCaCert, clientCertKey, clientCert));
}
#! /usr/bin/env node
const fs = require('fs')
const program = require('commander')
const { DgraphClientStub, DgraphClient, Operation } = require('dgraph-js')
const stub = new DgraphClientStub()
const client = new DgraphClient(stub)
const dropAll = () => {
const op = new Operation()
op.setDropAll(true)
return client.alter(op)
}
program
.arguments('')
.option('-s, --schema ', 'The schema to update')
.action((action, options) => {
if (action === 'update') {
const { Client } = require('./client')
const client2 = new Client({ relay: false, debug: false })
const schema = fs.readFileSync(options.schema).toString()
function newClientStub() {
return new dgraph.DgraphClientStub("localhost:9080", grpc.credentials.createInsecure());
}
function newClientStub() {
return new dgraph.DgraphClientStub("localhost:9080", grpc.credentials.createInsecure());
}
import { DgraphClientStub, DgraphClient, Operation, Mutation } from 'dgraph-js'
import { parse, GraphQLSchema, Source } from 'graphql'
import transformSchema from './transformSchema'
import buildSchema from './buildSchema'
import getInfo from './getInfo'
import type { SchemaInfo } from './getInfo'
export type ClientConfig = {
relay?: boolean,
debug?: boolean
}
const stub = new DgraphClientStub()
const client = new DgraphClient(stub)
const updateTypeName = 'SchemaUpdate'
export class Client {
_info: SchemaInfo
_debug: boolean
init: Promise
schema: GraphQLSchema
relay: boolean
constructor (config: ClientConfig) {
this._debug = config.debug || false
this.init = this.loadSchema()
this.relay = config.relay || false
}
import { DgraphClientStub, DgraphClient, Operation, Mutation } from "dgraph-js";
import { AccountEntry, Ledger, EntryType } from "./model";
import { Collection, Ingestor } from "./ingest";
import grpc from "grpc";
import logger from "./common/util/logger";
import { DEBUG_LEDGER } from "./common/util/secrets";
const clientStub = new DgraphClientStub("localhost:9080", grpc.credentials.createInsecure());
const client = new DgraphClient(clientStub);
const dropAll = async () => {
const op = new Operation();
op.setDropAll(true);
await client.alter(op);
}
const setSchema = async () => {
const schema = `
type: string @index(exact) .
seq: int @index(int) .
id: string @index(exact) .
`;
const op = new Operation();
op.setSchema(schema);