Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (host === 'http://user:pass@example.com:9200') {
throw new Error(
"✋ 🛑 I don't have public elasticsearch instance for demo purposes. \n" +
'🚀 Demo will work if you provide public elasticsearch instance url \n' +
'🚀 in query argument `host: "http://user:pass@example.com:9200"` \n'
);
}
}
const schemaComposer = new SchemaComposer();
schemaComposer.Query.setField('elastic60', {
description: 'Elastic v6.0',
type: schemaComposer.createObjectTC({
name: 'Elastic60',
fields: new ElasticApiParser({ version: '6_0', prefix: 'Elastic60' }).generateFieldMap(),
}),
args: {
host: {
type: 'String',
defaultValue: 'http://user:pass@example.com:9200',
},
},
resolve: (src, args, context) => {
checkHost(args.host);
context.elasticClient = new elasticsearch.Client({
// eslint-disable-line no-param-reassign
host: args.host,
apiVersion: '6.0',
requestTimeout: 5000,
});
return {};