An WPGraphQL extension that adds SearchWP's query functionality to the GraphQL server

Overview

QL Search

Build Status

What is QL Search?

An extension that integrates SearchWP into WPGraphQL.

Quick Install

  1. Install & activate SearchWP v3.1.9+
  2. Install & activate WPGraphQL v0.5.0+
  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, 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. 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.

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.

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 post object connection.

Comments
  • Using the after argument always returns an internal server error

    Using the after argument always returns an internal server error

    Running searchWP version 3.1.8 and gl-search version 1.0.0

    When running a searchWP query using the after argument if the after argument is anything but an empty string the query result will always be an internal server error.

    The graphql query:

    query SearchPages($term: String!, $after: String!) {
        searchWP(first: 1, after: $after, where: { input: $term, postType: PAGE }) {
            nodes {
                ... on Page {
                    id
                }
            }
            pageInfo {
                hasNextPage
                endCursor
            }
        }
    }
    

    The argument values:

    {
      "term": "test",
      "after": "YXJyYXljb25uZWN0aW9uOjUyNzY="
    }
    

    The query result:

    {
      "errors": [
        {
          "message": "Internal server error",
          "category": "internal",
          "locations": [
            {
              "line": 3,
              "column": 5
            }
          ],
          "path": [
            "searchWP"
          ]
        }
      ],
      "data": {
        "searchWP": null
      }
    }
    

    The endCursor value was taken from a previous query

    Its also worth noting that the README of the github says that the searchWP plugin must be version 3.1.9+ but the newest version of the plugin available on the website is 3.1.8.

    bug 
    opened by lwaldner 3
  • nuxt crashes on plugin install

    nuxt crashes on plugin install

    Describe the bug Nuxt apollo crashes when ql-search app is installed

    To Reproduce Steps to reproduce the behavior:

    1. Install searchWP plugin
    2. Install ql-search plugin

    Errors Nuxt crashes with error Network error: Unexpected end of JSON input visible from front end.

    WP-Graphql crashes with error: Fatal error: Uncaught TypeError: Argument 1 passed to WPGraphQL\SearchWP\Type_Registry::init() must be an instance of WPGraphQL\Registry\TypeRegistry, string given, called in /www/wp-includes/class-wp-hook.php on line 286 and defined in /www/wp-content/plugins/ql-search-master/includes/class-type-registry.php:20 Stack trace: #0 /www/wp-includes/class-wp-hook.php(286): WPGraphQL\SearchWP\Type_Registry->init('') #1 /www/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /www/wp-includes/plugin.php(465): WP_Hook->do_action(Array) #3 /www/wp-content/plugins/wp-graphql/src/TypeRegistry.php(242): do_action('graphql_registe...') #4 /www/wp-content/plugins/wp-graphql/wp-graphql.php(517): WPGraphQL\TypeRegistry::init() #5 /www/wp-content/plugins/wp-graphql/src/Request.php(85): WPGraphQL::get_schema() #6 /www/wp-content/plugins/wp-graphql/src/Router.php(339): WPGraphQL\Request->__construct() #7 /www/wp-content/plugins/wp-graphql/src/Router.php(153): WPGraphQL\Router::process_http_request() #8 /www/wp-include in /www/wp-content/plugins/ql-search-master/includes/class-type-registry.php on line 20

    visible from {wordpress-backend.com}/graphql

    Expected behavior Plugin should not crash app

    Additional context I installed on two different projects and received the same error

    opened by dChiamp 2
  • Fixes the number of results returned in a query

    Fixes the number of results returned in a query

    Your checklist for this pull request

    Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

    🚨Please review the guidelines for contributing to this repository.

    • [x] Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
    • [x] Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

    What does this implement/fix? Explain your changes.

    …

    Does this close any currently open issues?

    #4

    Any relevant logs, error output, GraphiQL screenshots, etc?

    (If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

    Any other comments?

    …

    Where has this been tested?

    Operating System: Linux Mint 19.2

    WordPress Version: 5.3.2

    opened by kidunot89 1
  • Not respecting

    Not respecting "first" setting in GQL

    We have 30 pages tagged with "VFX", but the search results will only return 20, because that is what "Read Settings" is set to. This makes sense from a SearchWP POV, but is not how the rest of WP-GQL works. I think when using this plugin it should respect first over the read settings.

    searchWP(first: 100, where: { input: $term, postType: PAGE })

    opened by drewbaker 1
  • WIP SearchWP 4.0 support

    WIP SearchWP 4.0 support

    Your checklist for this pull request

    Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

    🚨Please review the guidelines for contributing to this repository.

    • [x] Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
    • [x] Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

    What does this implement/fix? Explain your changes.

    Add SearchWP v4.0 support.

    • taxonomies parameter needs some works.
    • date and meta parameters broken.

    Does this close any currently open issues?

    …

    Any relevant logs, error output, GraphiQL screenshots, etc?

    (If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

    Any other comments?

    …

    Where has this been tested?

    Operating System: …

    WordPress Version: …

    opened by kidunot89 0
  • Patch for WPGraphQL#1111

    Patch for WPGraphQL#1111

    Your checklist for this pull request

    Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

    🚨Please review the guidelines for contributing to this repository.

    • [x] Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
    • [x] Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

    What does this implement/fix? Explain your changes.

    Add support for changes made in WPGraphQL#1111

    Does this close any currently open issues?

    …

    Any relevant logs, error output, GraphiQL screenshots, etc?

    (If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

    Any other comments?

    …

    Where has this been tested?

    Operating System: Linux 19.2

    WordPress Version: 5.3.2

    bugfix 
    opened by kidunot89 0
  • "SWP_Query_Cursor" implemented

    Your checklist for this pull request

    Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

    🚨Please review the guidelines for contributing to this repository.

    • [x] Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
    • [x] Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

    What does this implement/fix? Explain your changes.

    Adds pagination functionality to the searchWP query.

    Does this close any currently open issues?

    …

    Any relevant logs, error output, GraphiQL screenshots, etc?

    (If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

    Any other comments?

    …

    Where has this been tested?

    Operating System: Linux Mint 19.2

    WordPress Version: 5.3

    enhancement 
    opened by kidunot89 0
  • More SWP connection params

    More SWP connection params

    Your checklist for this pull request

    Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.

    🚨Please review the guidelines for contributing to this repository.

    • [x] Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
    • [x] Make sure you are requesting to pull request from a topic/feature/bugfix branch (right side). Don't pull request from your master!

    What does this implement/fix? Explain your changes.

    Adds more parameters on the SWP connection

    • [x] taxonomies
    • [x] meta
    • [x] date

    Does this close any currently open issues?

    …

    Any relevant logs, error output, GraphiQL screenshots, etc?

    (If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

    Any other comments?

    …

    Where has this been tested?

    Operating System: Linux Mint 19.2

    WordPress Version: 5.2.3

    enhancement 
    opened by kidunot89 0
  • Any query causes server error

    Any query causes server error "Class 'SearchWP\\Mod' not found"

    Describe the bug Any query causes internal server error:

    "Class 'SearchWP\\Mod' not found

    To Reproduce Steps to reproduce the behavior: Install required plugins and try a query like

      searchWP(where: {input: "test"}) {
        nodes {
          databaseId
        }
      }
    }
    

    Expected behavior Results should show up

    Plugin versions

    SearchWP 3.1.16 WP Graphql 1.6.10 QL Search 1.0.0

    opened by heggemsnes 1
  • Add support for wp-graphql-offset-pagination

    Add support for wp-graphql-offset-pagination

    Is your feature request related to a problem? Please describe. We're using wp-graphql-offset-pagination on our main query to provide a total count of returned objects. Our pagination component looks like

    [ < Previous ] Page 2 of 4 [ Next > ]

    and we can't calculate the "Page 2 of 4" without knowing the total number of results.

    Describe the solution you'd like It would be great if searchWP queries could support the offsetPagination input and state. Not sure how feasible that is or what it would take to make them compatible.

    Describe alternatives you've considered For now we're not displaying the total count for searchWP queries.

    opened by daltonrooney 2
Owner
Funkhaus
The creative's creative agency. Technical Director and co-founder @drewbaker.
Funkhaus
WPGraphQL Extension: Adds "meta_query" support to postObject connection queries using WP_Query

WPGraphQL Meta Query This plugin adds Meta_Query support to the WP GraphQL Plugin for postObject query args. Why is this an extension and not part of

WPGraphQL 42 Nov 10, 2022
Add WooCommerce support and functionality to your WPGraphQL server

WPGraphQL WooCommerce (WooGraphQL) Docs • AxisTaylor • Join Slack Quick Install Install & activate WooCommerce Install & activate WPGraphQL Download t

WPGraphQL 546 Jan 2, 2023
Adds Settings to the Custom Post Type UI plugin to show Post Types in WPGraphQL

DEPRECATION NOTICE ?? Custom Post Type UI v1.9.0 introduced formal support for WPGraphQL!!! ?? With that, this plugin is being deprecated and will no

WPGraphQL 77 Aug 3, 2022
WPGraphQL Polylang Extension for WordPress

WPGraphQL Polylang Extension Extend WPGraphQL schema with language data from the Polylang plugin. Features For posts and terms (custom ones too!) Adds

Valu Digital 102 Dec 29, 2022
This is an extension to the WPGraphQL plugin for Yoast SEO

WPGraphQl Yoast SEO Plugin Please note version 14 of the Yoast Plugin is a major update. If you are stuck on version of Yoast before V14 then use v3 o

Ashley Hitchcock 197 Dec 26, 2022
Query gutenberg blocks with wp-graphql

WPGraphQL Gutenberg Query gutenberg blocks through wp-graphql Usage Docs Join our community through WpGraphQL Slack Install Requires PHP 7.0+ Requires

null 270 Jan 3, 2023
Adds meta data registered via register_meta() to the GraphQL output.

WP GraphQL Meta This plugin is an add-on for the awesome WP GraphQL It builds on top of both WP GraphQL and the REST API. Any meta data you register u

Robert O'Rourke 18 Aug 4, 2021
Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.

Laravel Blog Have you worked with Wordpress? Developers call this package wordpress-like laravel blog. Contact us for any customization: contact@binsh

Binshops 279 Dec 28, 2022
Authentication for WPGraphQL using JWT (JSON Web Tokens)

WPGraphQL JWT Authentication This plugin extends the WPGraphQL plugin to provide authentication using JWT (JSON Web Tokens) JSON Web Tokens are an ope

WPGraphQL 268 Dec 31, 2022
[ALPHA] Implementation of persisted queries for WPGraphQL

WPGraphQL Persisted Queries Persisted GraphQL queries allow a GraphQL client to optimistically send a hash of the query instead of the full query; if

Quartz 18 Jun 20, 2022
Send emails via mutation using WpGraphQl

WPGraphQL Send Email Plugin One of the simple things about a traditional WordPress sites is sending emails, this plugin makes it easy to do this via a

Ashley Hitchcock 18 Aug 21, 2022
Structured content blocks for WPGraphQL

WPGraphQL Content Blocks (Structured Content) This WPGraphQL plugin returns a WordPress post’s content as a shallow tree of blocks and allows for some

Quartz 72 Oct 3, 2022
a wordpress plugin that improves wpgraphql usage together with wpml

WPGraphQL WPML Extension Contributors: rburgst Stable tag: 1.0.6 Tested up to: 5.6.1 Requires at least: 4.9 Requires PHP: 7.0 Requires WPGraphQL: 0.8.

null 42 Dec 15, 2022
WPGraphQL for Advanced Custom Fields

WPGraphQL for Advanced Custom Fields WPGraphQL for Advanced Custom Fields automatically exposes your ACF fields to the WPGraphQL Schema. Install and A

WPGraphQL 558 Jan 8, 2023
Wordpress wrapper to expose Carbon Fields to WpGraphQL queries.

WpGraphQLCrb A Wordpress wrapper to expose Carbon Fields to WpGraphQL queries. Important This is just the first version. There is a lot of work to be

Matheus Paiva 16 Aug 19, 2022
WPGraphQL FacetWP integration plguin

WPGraphQL-FacetWP: WPGraphQL provider for FacetWP Quick Install Download and install like any WordPress plugin. Documentation The WPGraphQL documentat

null 31 Dec 11, 2022
WPGraphQL for Meta Box

WPGraphQL-MetaBox: WPGraphQL provider for Meta Box Quick Install Download and install like any WordPress plugin. Documentation The WPGraphQL documenta

null 25 Aug 8, 2022
:rocket: GraphQL API for WordPress

WPGraphQL WPGraphQL is a free, open-source WordPress plugin that provides an extendable GraphQL schema and API for any WordPress site. Below are some

WPGraphQL 3.4k Jan 5, 2023
Makes WP GraphQL's authetication "just work". It does this by customizing the CORS headers.

WP GraphQL CORS The primary purpose of this plugin is to make the WP GraphQL plugin authentication "just work". It does this by allowing you set the C

Funkhaus 86 Jan 5, 2023