Extension

Internal GraphQL Server

Execute GraphQL queries directly within your application, using PHP code.

Logo
Target Image

This extension installs an internal GraphQL Server, that can be invoked within your application, using PHP code.

The internal GraphQL server is accessed via class GatoGraphQL\InternalGraphQLServer\GraphQLServer, through these three methods:

  • executeQuery: Execute a GraphQL query
  • executeQueryInFile: Execute a GraphQL query contained in a (.gql) file
  • executePersistedQuery: Execute a persisted GraphQL query (providing its ID as an int, or slug as a string) (the Persisted Queries extension is required)

These are the method signatures:

namespace GatoGraphQL\InternalGraphQLServer;
 
use PoP\Root\HttpFoundation\Response;
 
class GraphQLServer {
  /**
   * Execute a GraphQL query
   */
  public static function executeQuery(
    string $query,
    array $variables = [],
    ?string $operationName = null,
    int|string|null $schemaConfigurationIDOrSlug = null,
  ): Response {
    // ...
  }
 
 
  /**
   * Execute a GraphQL query contained in a (`.gql`) file
   */
  public static function executeQueryInFile(
    string $file,
    array $variables = [],
    ?string $operationName = null,
    int|string|null $schemaConfigurationIDOrSlug = null,
  ): Response {
    // ...
  }
 
 
  /**
   * Execute a persisted GraphQL query (providing its object
   * of type WP_Post, ID as an int, or slug as a string)
   */
  public static function executePersistedQuery(
    WP_Post|string|int $persistedQuery,
    array $variables = [],
    ?string $operationName = null
  ): Response {
    // ...
  }
}

To execute a GraphQL query and obtain the response content:

use GatoGraphQL\InternalGraphQLServer\GraphQLServer;
 
// Provide the GraphQL query
$query = "{ ... }";
 
// Execute the query against the internal server
$response = GraphQLServer::executeQuery($query);
 
// Get the content and decode it
$responseContent = json_decode($response->getContent(), true);
 
// Access the data and errors from the response
$responseData = $responseContent["data"] ?? [];
$responseErrors = $responseContent["errors"] ?? [];

Purchase extension

Personal
$249
(one-off)
“Power Extensions” bundle
License for 5 domains
Purchase ->
  • 5 domains
  • Support (forever)
  • Product updates (forever)
Organization
$499
(one-off)
“Power Extensions” bundle
License for 25 domains
Purchase ->
  • 25 domains
  • Support (forever)
  • Product updates (forever)
Professional
$749
(one-off)
“Power Extensions” bundle
License for 100 domains
Purchase ->
  • 100 domains
  • Support (forever)
  • Product updates (forever)

The license never expires. Prices are in USD.

30-day money back guarantee

Purchase any extension with the confidence that you can request a refund

Features illustration
Money back guarantee

Read our refund policy

Testimonial image

This plugin is next level!. It takes your site to a whole new level and turns it into a powerhouse. The more you explore what it can do, the more impressed you’ll be. If you’re on the fence—just grab it, you’ll kick yourself later if you don’t!. The documentation speaks for itself and is solid as it gets. Leo (the dev) is one of the sharpest and most switched-on developers I’ve ever come across. He’s super responsive and clearly knows his stuff. I’m honestly stoked with how much this plugin can do. The possibilities are pretty much endless, and if SEO matters to you, this thing will help your site rank hard.

olmate - Webdev

Subscribe to our newsletter

Stay in the loop on all new things concerning Gato GraphQL.