拡張機能

Internal GraphQL Server

PHPコードを使用して、アプリケーション内部から直接GraphQLクエリを実行します。

Logo
Target Image

この拡張機能は内部GraphQLサーバーをインストールします。このサーバーはPHPコードを使用して、アプリケーション内部から呼び出すことができます。

内部GraphQLサーバーには、クラス GatoGraphQL\InternalGraphQLServer\GraphQLServer を通じて、以下の3つのメソッドでアクセスします:

  • executeQuery: GraphQLクエリを実行する
  • executeQueryInFile: (.gql) ファイルに含まれるGraphQLクエリを実行する
  • executePersistedQuery: 保存されたGraphQLクエリを実行する(IDを整数で、またはスラグを文字列で指定)(Persisted Queries 拡張機能が必要)

メソッドのシグネチャは以下のとおりです:

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

GraphQLクエリを実行してレスポンスの内容を取得するには:

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 バンドルを購入

Personal
$79
/
“All-Inclusive” バンドル
ライセンス対象: 1 ドメイン
購入 ->
  • 1 ドメイン
  • サポート
  • 製品アップデート
Organization
$99
/
“All-Inclusive” バンドル
ライセンス対象: 3 ドメイン
購入 ->
  • 3 ドメイン
  • サポート
  • 製品アップデート
Professional
$199
/
“All-Inclusive” バンドル
ライセンス対象: 10 ドメイン
購入 ->
  • 10 ドメイン
  • サポート
  • 製品アップデート

ライセンスは1年間有効(毎年更新可能)です。価格は USD 表示です。

より多くのドメインが必要ですか?お問い合わせください

30日間の返金保証

各拡張機能は返金申請の保証付きで購入できます

Features illustration
Money back guarantee

返金ポリシーをご覧ください

Testimonial image

“このプラグインはまさに別次元です!サイトをまったく新しいレベルへと引き上げ、強力なパワーハウスに変えてくれます。できることを探れば探るほど、どんどん感動が深まります。迷っているなら、とにかく入手してください。後で後悔することになりますよ。 ドキュメントはそれ自体が雄弁に語っており、これ以上ないほど充実しています。 Leo(開発者)は、これまで出会った中で最も鋭く、機転の利く開発者の一人です。レスポンスは非常に速く、自分の専門分野を完全に把握していることが伝わります。このプラグインがここまで多くのことを実現できることに、心から興奮しています。可能性はほぼ無限大で、SEOを重視しているなら、このプラグインがサイトの順位を大きく押し上げてくれるでしょう。”

olmate - Webデベロッパー

ニュースレターを購読する

Gato GraphQL のすべてのアップデートを把握しましょう。