Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elasticsearch-graphql

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elasticsearch-graphql - npm Package Compare versions

Comparing version 1.1.3 to 2.0.0

39

index.js
var elasticsearch = require('elasticsearch')
function init (opts, cb) {
if (!opts.graphql || !opts.graphql.GraphQLInt) return cb(new Error('Missing graphql option, needed for internal reference'))
if (!opts.elastic.index) return cb(new Error('Missing elastic search index to fetch mapping from'))
if (!opts.elastic.type) return cb(new Error('Missing elastic search type to fetch mapping from'))
function init (opts) {
if (!opts.graphql || !opts.graphql.GraphQLInt) throw new Error('Missing graphql option, needed for internal reference')
if (!opts.elastic.index) throw new Error('Missing elastic search index to fetch mapping from')
if (!opts.elastic.type) throw new Error('Missing elastic search type to fetch mapping from')
if (!opts.mapping) throw new Error('Missing elastic mapping')

@@ -19,31 +20,9 @@ if (opts.elastic.host) {

return new Promise(function (resolve, reject) {
if (opts.elastic.mapping) return resolve(opts.elastic.mapping)
var mapping = opts.mapping.mappings[opts.elastic.type]
var properties = mapping.properties
var transform = mapping.transform
opts.client.indices.getMapping({
index: opts.elastic.index,
type: opts.elastic.type
}, function (err, res) {
if (err) return reject(err)
resolve(res)
})
})
.then(function (response) {
var indexes = Object.keys(response)
var mapping = response[indexes[0]].mappings[opts.elastic.type]
var properties = mapping.properties
var transform = mapping.transform
cb && cb(null, schemaBuilder(opts, properties, transform))
return schemaBuilder(opts, properties, transform)
})
.catch(function (err) {
cb && cb(err)
return err
})
return schemaBuilder(opts, properties, transform)
}
module.exports = init

@@ -107,3 +107,4 @@ var _ = require('lodash')

var body = {
_source: false
_source: false,
size: params.limit
}

@@ -110,0 +111,0 @@

@@ -63,9 +63,3 @@ var aggregations = require('./aggregations')

},
hits: {
type: new graphql.GraphQLList(opts.hitsSchema.type),
args: opts.hitsSchema.args,
resolve: function (response) {
return opts.hitsSchema.resolve(response.hits.hits)
}
}
hits: opts.hitsSchema
}

@@ -72,0 +66,0 @@ }

{
"name": "elasticsearch-graphql",
"version": "1.1.3",
"version": "2.0.0",
"description": "Schema generator and query builder for elasticsearch",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc