josephfusco/wpgraphiql-query-injector

Inject a custom query and variables into the WPGraphiQL editor

1.0.0 2023-10-22 19:33 UTC

This package is auto-updated.

Last update: 2024-10-22 21:43:37 UTC


README

Overview

WPGraphiQL Query Injector is a WordPress plugin designed to inject custom GraphQL queries and variables into your WPGraphiQL editor. The plugin aims to provide a straightforward way to populate the WPGraphiQL editor within a WordPress Playground environment.

Usage

Once the plugin is activated, it will automatically populate the WPGraphiQL editor with predefined queries and variables. You can modify these by applying WordPress filters.

Filters

wpgraphiql_query

Filter the GraphiQL Query input.

add_filter( 'wpgraphiql_query', function() {
    return <<<GRAPHQL
      query GeneralSettings {
        allSettings {
          siteTitle: generalSettingsTitle
          sideDescription: generalSettingsDescription
        }
      }
      GRAPHQL
});

wpgraphiql_variables

Filter the GraphiQL Variables input.

add_filter( 'wpgraphiql_variables', function() {
    return <<<JSON
      {
        "id": 716
      }
      JSON;
});

wpgraphiql_use_public_fetcher

Filter auth vs public requests.

add_filter( 'wpgraphiql_use_public_fetcher', function() {
  return 'true';
});