drupal-graphql / graphql-search-api

GraphQL & Drupal Search API integration.
10 stars 22 forks source link

Add ability to pass Search API Query options vias SearchAPISearch arguments #43

Closed MurzNN closed 3 years ago

MurzNN commented 3 years ago

Sometimes we need to pass specific custom options to Search API Query, for example to use search_api_location options (example). At now there are no ability to pass raw options to Search API Query via SearchAPISearch GraphQL function.

This PR adds the options argument, that can receive options and pass them to Search API Query.

Query example:

query {
  searchAPISearch(
    index_id: "geo_points"
   options: [
     {
       name: "search_api_location"
       json: "[{\"field\":\"geolocation\",\"lat\":56.304645,\"lon\":43.833524,\"radius\":50}]"
     }
   ],
    sort: {
      field: "geolocation", value: "ASC"
    }
  ) {
    result_count,
    documents {
      ... on GeoPointsDoc {
        id, label, geolocation
      }
    } 
  }
}

Please review it and comment, if something need to be reworked.

MurzNN commented 3 years ago

Soo, can anybody review my PR?

duartegarin commented 3 years ago

Hi @MurzNN , Thanks for the PR and apologies for the late reply, been pretty swamped lately. This looks good, just wondering why you've added a composer.json file to the module? Doesn't seem necessary. Cheers

MurzNN commented 3 years ago

@duartegarin About composer.json - I added it because most of other Drupal modules already have it, for better description in composer commands, and ability to set a requirements, if needed be. For example, you can declare support of Drupal core versions via line like:

    "require": {
        "drupal/core": "^8.9 || ^9",
    },

If it is not needed, I can remove it.

duartegarin commented 3 years ago

I think that's sensible @MurzNN , merging.