Erweiterung

Internal GraphQL Server

Führe GraphQL-queries direkt in deiner Anwendung aus, mit PHP-Code.

Logo
Target Image

Diese Erweiterung installiert einen internen GraphQL-Server, der innerhalb deiner Anwendung per PHP-Code aufgerufen werden kann.

Der interne GraphQL-Server wird über die Klasse GatoGraphQL\InternalGraphQLServer\GraphQLServer zugegriffen, durch diese drei Methoden:

  • executeQuery: Führt eine GraphQL-query aus
  • executeQueryInFile: Führt eine GraphQL-query aus, die in einer (.gql)-Datei enthalten ist
  • executePersistedQuery: Führt eine persisted GraphQL-query aus (mit der ID als Integer oder dem Slug als String) (die Erweiterung Persisted Queries ist erforderlich)

Dies sind die Methodensignaturen:

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 {
    // ...
  }
}

Um eine GraphQL-query auszuführen und den Antwortinhalt zu erhalten:

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"] ?? [];

All-Inclusive-Paket kaufen

Personal
$79
/Jahr
“All-Inclusive” Paket
Lizenz für 1 Domain
Kaufen ->
  • 1 Domain
  • Support
  • Produktaktualisierungen
Organization
$99
/Jahr
“All-Inclusive” Paket
Lizenz für 3 Domains
Kaufen ->
  • 3 Domains
  • Support
  • Produktaktualisierungen
Professional
$199
/Jahr
“All-Inclusive” Paket
Lizenz für 10 Domains
Kaufen ->
  • 10 Domains
  • Support
  • Produktaktualisierungen

Die Lizenz gilt für 1 Jahr (jährlich verlängerbar). Die Preise sind in USD.

Brauchst du mehr Domains? Kontaktiere uns

30 Tage Geld-zurück-Garantie

Kaufe jede Erweiterung mit der Gewissheit, dass du eine Rückerstattung anfordern kannst

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

Abonniere unseren Newsletter

Bleib über alle Updates zu Gato GraphQL auf dem Laufenden.