Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funkhaus/ql-search
An WPGraphQL extension that adds SearchWP's query functionality to the GraphQL server
https://github.com/funkhaus/ql-search
Last synced: 2 months ago
JSON representation
An WPGraphQL extension that adds SearchWP's query functionality to the GraphQL server
- Host: GitHub
- URL: https://github.com/funkhaus/ql-search
- Owner: funkhaus
- License: gpl-3.0
- Archived: true
- Created: 2019-11-15T01:16:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-23T16:59:17.000Z (about 4 years ago)
- Last Synced: 2024-08-02T05:15:15.698Z (5 months ago)
- Language: PHP
- Homepage:
- Size: 292 KB
- Stars: 13
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-wordpress-gatsby - QL Search - An extension that integrates SearchWP into WPGraphQL. (Plugins / WordPress)
README
# QL Search
[![Build Status](https://travis-ci.org/funkhaus/ql-search.svg?branch=master)](https://travis-ci.org/funkhaus/ql-search)## What is QL Search?
An extension that integrates [SearchWP](https://searchwp.com) into [WPGraphQL](https://www.wpgraphql.com).## Quick Install
1. Install & activate [SearchWP *v3.1.9+*](https://searchwp.com)
2. Install & activate [WPGraphQL *v0.5.0+*](https://www.wpgraphql.com)
3. Clone or download the zip of this repository into your WordPress plugin directory & activate the plugin.## Features
- Search across multiple post-types.
- Filter taxonomy, meta, date, and more...## Some Examples
### Query multiple types with a single `input`.
```
query {
searchWP(first: 5, where: { input: "Hello World" }) {
nodes {
... on Post {
id
}
... on Page {
id
}
}
}
}
```
The `input` parameter is the base search field, and request on all `searchWP` queries.### Query with an alternative `engine`.
```
query {
searchWP(first: 5, where: { input: "Hello World", engine: "other-engine-slug" }) {
nodes {
... on Post {
id
... more post fields
}
... on Page {
id
... more page fields
}
}
}
}
```
The `engine` parameter by default is set to *default*. An important thing to remember is that in order for a post-type to be returned as an `searchWP` result be enable on the **SearchWP** engine, Find out more about SearchWP's engine configuration [here](https://searchwp.com/docs/configuration/), and it must have `exclude_from_search` set to `false` and `show_in_graphql` set to `true` in it's **Post-type** configurations.### Query by `taxonomies`.
```
query {
searchWP(first: 5, where: { input: "Hello World", taxonomies: { taxArray: [{ taxonomy: TAG, field: SLUG, terms: "test_tag" }] } }) {
nodes {
... on Post {
id
... more post fields
}
... on Page {
id
... more page fields
}
}
}
}
```
The `taxonomies` parameter is designed to be identical to the enhanced `taxQuery` parameter used by **[WPGraphQL Tax Query](https://github.com/wp-graphql/wp-graphql-tax-query)**. Another important thing to remember about **SearchWP** and by relation **QL Search**, is that in order to query a specific taxonomy, that taxonomy must be given a weight on the *engine* being used. In the cause of the query above that is the default engine. Find out more about SearchWP's engine configuration [here](https://searchwp.com/docs/configuration/).### Query by `meta`.
```
query {
searchWP(first: 5, where: { input: "Hello World", meta: { metaArray: [{ key: "test_meta", value: "meta value", compare: EQUAL_TO }] } }) {
nodes {
... on Post {
id
... more post fields
}
... on Page {
id
... more page fields
}
}
}
}
```
The `meta` parameter is designed to be identical to the enhanced `metaQuery` parameter used by **[WPGraphQL Meta Query](https://github.com/wp-graphql/wp-graphql-meta-query)**.### Query by `date`.
```
query {
searchWP(first: 5, where: { input: "Hello World", date: [{ year: 1970, month: 1, day: 1 }] }) {
nodes {
... on Post {
id
... more post fields
}
... on Page {
id
... more page fields
}
}
}
}
```
The `date` parameter is designed to be identical to the `date` parameter on the core [WPGraphQL](https://github.com/wp-graphql/wp-graphql) post object connection.