graphql-compose-elasticsearch icon indicating copy to clipboard operation
graphql-compose-elasticsearch copied to clipboard

pass custom query to composeWithElastic

Open karladler opened this issue 4 years ago • 1 comments

is it somehow possible to add custom queries to the elastic query already when defining the GraphQL objects? I wan't to add a filter to my query to retrieve only Users from elastic which have the flag isCustomer set. I couldn't find any doc for this. There seems to be an "opts" fields, but not sure how to use it.

const CustomerES = composeWithElastic({
  graphqlTypeName: 'UserES',
  elasticIndex: 'users',
  elasticType: '_doc',
  elasticMapping: properties,
  elasticClient,
  pluralFields: ['orders'],
  opts: {
    query: {
      isCustomer: true,
    },
  },
});

sorry if this question is stupid, I'm just starting GraphQL and elastic ;)

karladler avatar Mar 19 '20 20:03 karladler

I have the same doubt! Would be super useful if someone could answer this :)

Pythonista7 avatar Aug 14 '21 17:08 Pythonista7