How to use graphql-compose-elasticsearch - 1 common examples

To help you get started, we’ve selected a few graphql-compose-elasticsearch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-compose / graphql-compose-examples / examples / elasticsearch / schema.js View on Github external
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 {};

graphql-compose-elasticsearch

Elastic search via GraphQL

MIT
Latest version published 2 years ago

Package Health Score

42 / 100
Full package analysis

Popular graphql-compose-elasticsearch functions