Schema Functions
Schema FunctionsHTTP Request via Schema

HTTP Request via Schema

Included in the “Power Extensions” bundle

現在のHTTPリクエストデータを取得するためのフィールドをGraphQLスキーマに追加します。

フィールド一覧

以下のフィールドがスキーマに追加されます。

_httpRequestBody

HTTPリクエストのボディ。

_httpRequestClientHost

クライアントのホスト。

_httpRequestClientIP

クライアントのIPアドレスを取得します。サーバーが適切に設定されていない場合(下記参照)、レスポンスは null になります。

設定

クライアントのIPアドレスは $_SERVER グローバル変数から取得され、通常はプロパティ 'REMOTE_ADDR' から取得されます。ただし、プラットフォームによってはこの情報を取得するために異なるプロパティ名を使用する必要がある場合があります。

例:

  • Cloudflare では 'HTTP_CF_CONNECTING_IP' を使用する場合があります
  • AWS では 'HTTP_X_FORWARDED_FOR' を使用する場合があります

使用するプロパティ名は、設定ページの「Plugin Configuration > Server IP Configuration」タブで設定できます。

クライアントIPを取得するための$_SERVERプロパティ名の設定
クライアントIPを取得するための$_SERVERプロパティ名の設定

_httpRequestCookie

リクエストのクッキー値。

_httpRequestCookies

リクエストのクッキー。

_httpRequestDomain

リクエストされたURLのドメイン。

_httpRequestFullURL

リクエストされたURL(クエリパラメーターを含む)。

_httpRequestHasCookie

リクエストに特定のクッキーが含まれているかどうか。

_httpRequestHasHeader

リクエストに特定のヘッダーが含まれているかどうか。

_httpRequestHasParam

リクエストに特定のパラメーターが含まれているかどうか。

_httpRequestHeader

リクエストのヘッダー値。

_httpRequestHeaders

リクエストのヘッダー。

_httpRequestHost

リクエストされたURLのホスト。

_httpRequestMethod

リクエストのメソッド。

_httpRequestParams

すべてのパラメーター(POSTまたはGETで渡される)を含むJSONオブジェクト。

パラメーターの値は以下のいずれかになります。

  • 文字列(String): ?param=value
  • 配列(Array): ?someArray[]=1&someArray[]=2
  • 配列の配列(Array of arrays): ?someMatrix[0][0]=3&someMatrix[0][1]=4&someMatrix[1][0]=5&someMatrix[1][1]=6
  • 連想配列(オブジェクト): ?someAssocArray["admins"]=20&someAssocArray["authors"]=30
  • 連想配列の配列: ?someAssocMatrix["admins"][0]=7&someAssocMatrix["admins"][1]=8&someAssocMatrix["authors"][0]=9&someAssocMatrix["authors"][1]=10
  • その他の組み合わせ

パラメーターの値を取得するには、最初の2つのケースにそれぞれ _httpRequestStringParam フィールドと _httpRequestStringListParam フィールドを使用できますが、それ以外のケースに対応するフィールドはありません。

それらのケースには、このフィールド _httpRequestParams を使用してJSONオブジェクトを取得し、その中から対応する値を取り出してください。

_httpRequestProtocol

リクエストのプロトコル。

_httpRequestQuery

クエリパラメーターの文字列。

_httpRequestReferer

リクエストのリファラー。

_httpRequestRequestTime

リクエスト開始時のタイムスタンプ。

_httpRequestScheme

リクエストされたURLのスキーム。

_httpRequestServerIP

サーバーのIPアドレス。

_httpRequestStringListParam

?param[]=value1&param[]=value2 形式のパラメーター(POSTまたはGETで渡される)の値。

_httpRequestStringParam

?param=value 形式のパラメーター(POSTまたはGETで渡される)の値。

_httpRequestURL

リクエストされたURL(クエリパラメーターを除く)。

_httpRequestURLPath

リクエストされたURLの絶対パス(「/」で始まる)。

_httpRequestUserAgent

ユーザーエージェント。

使用例

次のクエリ:

query {
  _httpRequestHeaders
  existingHeader: _httpRequestHeader(name: "Accept")
  caseInsensitiveExistingHeader: _httpRequestHeader(name: "accept")
  nonExistingHeader: _httpRequestHeader(name: "Non-existing")
  existingHasHeader: _httpRequestHasHeader(name: "Accept")
  caseInsensitiveExistingHasHeader: _httpRequestHasHeader(name: "accept")
  nonExistingHasHeader: _httpRequestHasHeader(name: "Non-existing")
  _httpRequestBody
  _httpRequestMethod
  _httpRequestDomain
  _httpRequestScheme
  _httpRequestHost
  _httpRequestURL
  _httpRequestFullURL
  _httpRequestURLPath
  _httpRequestQuery
  _httpRequestParams
  existingParam: _httpRequestStringParam(name: "page")
  caseInsensitiveExistingParam: _httpRequestStringParam(name: "PAge")
  existingArrayParam: _httpRequestStringListParam(name: "someArray")
  nonExistingParam: _httpRequestStringParam(name: "also-non-existing")
  nonExistingListParam: _httpRequestStringListParam(name: "also-non-existing")
  existingHasParam: _httpRequestHasParam(name: "page")
  caseInsensitiveExistingHasParam: _httpRequestHasParam(name: "PAge")
  nonExistingHasParam: _httpRequestHasParam(name: "also-non-existing")
  existingCookie: _httpRequestCookie(name: "wordpress_test_cookie")
  caseInsentiveExistingCookie: _httpRequestCookie(name: "Wordpress_Test_Cookie")
  nonExistingCookie: _httpRequestCookie(name: "not_existing")
  existingHasCookie: _httpRequestHasCookie(name: "wordpress_test_cookie")
  caseInsentiveExistingHasCookie: _httpRequestHasCookie(name: "Wordpress_Test_Cookie")
  nonExistingHasCookie: _httpRequestHasCookie(name: "not_existing")
  _httpRequestProtocol
  _httpRequestReferer
  _httpRequestServerIP
  _httpRequestClientIP
  _httpRequestClientHost
  _httpRequestUserAgent
  _httpRequestCookies
  _httpRequestRequestTime
}

...の結果:

{
  "data": {
    "_httpRequestHeaders": {
      "authorization": "",
      "host": "gato-graphql-pro.lndo.site",
      "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0",
      "content-length": "1924",
      "accept": "application/json",
      "accept-encoding": "gzip, deflate, br",
      "accept-language": "en-US,en;q=0.5",
      "content-type": "application/json",
      "cookie": "wordpress_sec_f21902903273c44cc3a47d07e23af599=admin%7C1687924210%7CcMlLArK65w5nACJHlglLMMd52rRVZRmu2LRUJmCi7n1%7Cad6b03a20093f342a4107076432f7857e244174ab4d866c1887417c2e304e3fe; wp-settings-time-1=1686559494; wp-settings-1=libraryContent%3Dbrowse; wordpress_test_cookie=WP%20Cookie%20check; wp_lang=en_US; wordpress_logged_in_f21902903273c44cc3a47d07e23af599=admin%7C1687924210%7CcMlLArK65w5nACJHlglLMMd52rRVZRmu2LRUJmCi7n1%7C0ec85ac4a275aff3c464e139d40061aa0062a4e7376666b99ec8063a6715788a",
      "dnt": "1",
      "origin": "https://gato-graphql-pro.lndo.site",
      "referer": "https://gato-graphql-pro.lndo.site/wp-admin/admin.php?page=gatographql&query=%7B%0A%20%20_httpRequestHeaders%0A%20%20existingHeader%3A%20_httpRequestHeader(name%3A%20%22Accept%22)%0A%20%20caseInsensitiveExistingHeader%3A%20_httpRequestHeader(name%3A%20%22accept%22)%0A%20%20nonExistingHeader%3A%20_httpRequestHeader(name%3A%20%22Non-existing%22)%0A%20%20existingHasHeader%3A%20_httpRequestHasHeader(name%3A%20%22Accept%22)%0A%20%20caseInsensitiveExistingHasHeader%3A%20_httpRequestHasHeader(name%3A%20%22accept%22)%0A%20%20nonExistingHasHeader%3A%20_httpRequestHasHeader(name%3A%20%22Non-existing%22)%0A%20%20_httpRequestBody%0A%20%20_httpRequestMethod%0A%20%20_httpRequestDomain%0A%20%20_httpRequestScheme%0A%20%20_httpRequestHost%0A%20%20_httpRequestURL%0A%20%20_httpRequestFullURL%0A%20%20_httpRequestURLPath%0A%20%20_httpRequestQuery%0A%20%20_httpRequestParams%0A%20%20existingParam%3A%20_httpRequestStringParam(name%3A%20%22page%22)%0A%20%20caseInsensitiveExistingParam%3A%20_httpRequestStringParam(name%3A%20%22PAge%22)%0A%20%20existingArrayParam%3A%20_httpRequestStringListParam(name%3A%20%22someArray%22)%0A%20%20nonExistingParam%3A%20_httpRequestStringParam(name%3A%20%22also-non-existing%22)%0A%20%20nonExistingListParam%3A%20_httpRequestStringListParam(name%3A%20%22also-non-existing%22)%0A%20%20existingHasParam%3A%20_httpRequestHasParam(name%3A%20%22page%22)%0A%20%20caseInsensitiveExistingHasParam%3A%20_httpRequestHasParam(name%3A%20%22PAge%22)%0A%20%20nonExistingHasParam%3A%20_httpRequestHasParam(name%3A%20%22also-non-existing%22)%0A%20%20existingCookie%3A%20_httpRequestCookie(name%3A%20%22wordpress_test_cookie%22)%0A%20%20caseInsentiveExistingCookie%3A%20_httpRequestCookie(name%3A%20%22Wordpress_Test_Cookie%22)%0A%20%20nonExistingCookie%3A%20_httpRequestCookie(name%3A%20%22not_existing%22)%0A%20%20existingHasCookie%3A%20_httpRequestHasCookie(name%3A%20%22wordpress_test_cookie%22)%0A%20%20caseInsentiveExistingHasCookie%3A%20_httpRequestHasCookie(name%3A%20%22Wordpress_Test_Cookie%22)%0A%20%20nonExistingHasCookie%3A%20_httpRequestHasCookie(name%3A%20%22not_existing%22)%0A%20%20_httpRequestProtocol%0A%20%20_httpRequestReferer%0A%20%20_httpRequestServerIP%0A%20%20_httpRequestClientIP%0A%20%20_httpRequestClientHost%0A%20%20_httpRequestUserAgent%0A%0A%20%20_httpRequestCookies%0A%20%20_httpRequestRequestTime%0A%7D&variables=%7B%2B%2B%22postID%22%3A%2B40%2C%2B%2B%22translateToLang%22%3A%2B%22es%22%7D&operationName=SendEmail",
      "sec-fetch-dest": "empty",
      "sec-fetch-mode": "cors",
      "sec-fetch-site": "same-origin",
      "sec-gpc": "1",
      "te": "trailers",
      "x-forwarded-for": "172.19.0.1",
      "x-forwarded-host": "gato-graphql-pro.lndo.site",
      "x-forwarded-port": "443",
      "x-forwarded-proto": "https",
      "x-forwarded-server": "6de0a38d2bbe",
      "x-lando": "on",
      "x-real-ip": "172.19.0.1",
      "x-wp-nonce": "258a8aed3b"
    },
    "existingHeader": "application/json",
    "caseInsensitiveExistingHeader": "application/json",
    "nonExistingHeader": null,
    "existingHasHeader": true,
    "caseInsensitiveExistingHasHeader": true,
    "nonExistingHasHeader": false,
    "_httpRequestBody": "{\"query\":\"{\\n  _httpRequestHeaders\\n  existingHeader: _httpRequestHeader(name: \\\"Accept\\\")\\n  caseInsensitiveExistingHeader: _httpRequestHeader(name: \\\"accept\\\")\\n  nonExistingHeader: _httpRequestHeader(name: \\\"Non-existing\\\")\\n  existingHasHeader: _httpRequestHasHeader(name: \\\"Accept\\\")\\n  caseInsensitiveExistingHasHeader: _httpRequestHasHeader(name: \\\"accept\\\")\\n  nonExistingHasHeader: _httpRequestHasHeader(name: \\\"Non-existing\\\")\\n  _httpRequestBody\\n  _httpRequestMethod\\n  _httpRequestDomain\\n  _httpRequestScheme\\n  _httpRequestHost\\n  _httpRequestURL\\n  _httpRequestFullURL\\n  _httpRequestURLPath\\n  _httpRequestQuery\\n  _httpRequestParams\\n  existingParam: _httpRequestStringParam(name: \\\"page\\\")\\n  caseInsensitiveExistingParam: _httpRequestStringParam(name: \\\"PAge\\\")\\n  existingArrayParam: _httpRequestStringListParam(name: \\\"someArray\\\")\\n  nonExistingParam: _httpRequestStringParam(name: \\\"also-non-existing\\\")\\n  nonExistingListParam: _httpRequestStringListParam(name: \\\"also-non-existing\\\")\\n  existingHasParam: _httpRequestHasParam(name: \\\"page\\\")\\n  caseInsensitiveExistingHasParam: _httpRequestHasParam(name: \\\"PAge\\\")\\n  nonExistingHasParam: _httpRequestHasParam(name: \\\"also-non-existing\\\")\\n  existingCookie: _httpRequestCookie(name: \\\"wordpress_test_cookie\\\")\\n  caseInsentiveExistingCookie: _httpRequestCookie(name: \\\"Wordpress_Test_Cookie\\\")\\n  nonExistingCookie: _httpRequestCookie(name: \\\"not_existing\\\")\\n  existingHasCookie: _httpRequestHasCookie(name: \\\"wordpress_test_cookie\\\")\\n  caseInsentiveExistingHasCookie: _httpRequestHasCookie(name: \\\"Wordpress_Test_Cookie\\\")\\n  nonExistingHasCookie: _httpRequestHasCookie(name: \\\"not_existing\\\")\\n  _httpRequestProtocol\\n  _httpRequestReferer\\n  _httpRequestServerIP\\n  _httpRequestClientIP\\n  _httpRequestClientHost\\n  _httpRequestUserAgent\\n\\n  _httpRequestCookies\\n  _httpRequestRequestTime\\n}\",\"variables\":{\"postID\":40,\"translateToLang\":\"es\"}}",
    "_httpRequestMethod": "POST",
    "_httpRequestDomain": "lndo.site",
    "_httpRequestScheme": "https",
    "_httpRequestHost": "gato-graphql-pro.lndo.site",
    "_httpRequestURL": "https://gato-graphql-pro.lndo.site/wp-admin/edit.php",
    "_httpRequestFullURL": "https://gato-graphql-pro.lndo.site/wp-admin/edit.php?page=gatographql&action=run_query",
    "_httpRequestURLPath": "/wp-admin/edit.php",
    "_httpRequestQuery": "page=gatographql&action=run_query",
    "_httpRequestParams": {
      "page": "gatographql",
      "action": "run_query"
    },
    "existingParam": "gatographql",
    "caseInsensitiveExistingParam": null,
    "existingArrayParam": null,
    "nonExistingParam": null,
    "nonExistingListParam": null,
    "existingHasParam": true,
    "caseInsensitiveExistingHasParam": false,
    "nonExistingHasParam": false,
    "existingCookie": "WP Cookie check",
    "caseInsentiveExistingCookie": null,
    "nonExistingCookie": null,
    "existingHasCookie": true,
    "caseInsentiveExistingHasCookie": false,
    "nonExistingHasCookie": false,
    "_httpRequestProtocol": "HTTP/1.1",
    "_httpRequestReferer": "https://gato-graphql-pro.lndo.site/wp-admin/admin.php?page=gatographql&query=%7B%0A%20%20_httpRequestHeaders%0A%20%20existingHeader%3A%20_httpRequestHeader(name%3A%20%22Accept%22)%0A%20%20caseInsensitiveExistingHeader%3A%20_httpRequestHeader(name%3A%20%22accept%22)%0A%20%20nonExistingHeader%3A%20_httpRequestHeader(name%3A%20%22Non-existing%22)%0A%20%20existingHasHeader%3A%20_httpRequestHasHeader(name%3A%20%22accept%22)%0A%20%20caseInsensitiveExistingHasHeader%3A%20_httpRequestHasHeader(name%3A%20%22accept%22)%0A%20%20nonExistingHasHeader%3A%20_httpRequestHasHeader(name%3A%20%22Non-existing%22)%0A%20%20_httpRequestBody%0A%20%20_httpRequestMethod%0A%20%20_httpRequestDomain%0A%20%20_httpRequestScheme%0A%20%20_httpRequestHost%0A%20%20_httpRequestURL%0A%20%20_httpRequestFullURL%0A%20%20_httpRequestURLPath%0A%20%20_httpRequestQuery%0A%20%20_httpRequestParams%0A%20%20existingParam%3A%20_httpRequestStringParam(name%3A%20%22page%22)%0A%20%20caseInsensitiveExistingParam%3A%20_httpRequestStringParam(name%3A%20%22PAge%22)%0A%20%20existingArrayParam%3A%20_httpRequestStringListParam(name%3A%20%22someArray%22)%0A%20%20nonExistingParam%3A%20_httpRequestStringParam(name%3A%20%22also-non-existing%22)%0A%20%20nonExistingListParam%3A%20_httpRequestStringListParam(name%3A%20%22also-non-existing%22)%0A%20%20existingHasParam%3A%20_httpRequestHasParam(name%3A%20%22page%22)%0A%20%20caseInsensitiveExistingHasParam%3A%20_httpRequestHasParam(name%3A%20%22PAge%22)%0A%20%20nonExistingHasParam%3A%20_httpRequestHasParam(name%3A%20%22also-non-existing%22)%0A%20%20existingCookie%3A%20_httpRequestCookie(name%3A%20%22wordpress_test_cookie%22)%0A%20%20caseInsentiveExistingCookie%3A%20_httpRequestCookie(name%3A%20%22Wordpress_Test_Cookie%22)%0A%20%20nonExistingCookie%3A%20_httpRequestCookie(name%3A%20%22not_existing%22)%0A%20%20existingHasCookie%3A%20_httpRequestHasCookie(name%3A%20%22wordpress_test_cookie%22)%0A%20%20caseInsentiveExistingHasCookie%3A%20_httpRequestHasCookie(name%3A%20%22Wordpress_Test_Cookie%22)%0A%20%20nonExistingHasCookie%3A%20_httpRequestHasCookie(name%3A%20%22not_existing%22)%0A%20%20_httpRequestProtocol%0A%20%20_httpRequestReferer%0A%20%20_httpRequestServerIP%0A%20%20_httpRequestClientIP%0A%20%20_httpRequestClientHost%0A%20%20_httpRequestUserAgent%0A%0A%20%20_httpRequestCookies%0A%20%20_httpRequestRequestTime%0A%7D&variables=%7B%2B%2B%22postID%22%3A%2B40%2C%2B%2B%22translateToLang%22%3A%2B%22es%22%7D&operationName=SendEmail",
    "_httpRequestServerIP": "172.19.0.4",
    "_httpRequestClientIP": "172.19.0.2",
    "_httpRequestClientHost": null,
    "_httpRequestUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0",
    "_httpRequestCookies": {
      "wordpress_sec_f21902903273c44cc3a47d07e23af599": "admin|1687924210|cMlLArK65w5nACJHlglLMMd52rRVZRmu2LRUJmCi7n1|ad6b03a20093f342a4107076432f7857e244174ab4d866c1887417c2e304e3fe",
      "wp-settings-time-1": "1686559494",
      "wp-settings-1": "libraryContent=browse",
      "wordpress_test_cookie": "WP Cookie check",
      "wp_lang": "en_US",
      "wordpress_logged_in_f21902903273c44cc3a47d07e23af599": "admin|1687924210|cMlLArK65w5nACJHlglLMMd52rRVZRmu2LRUJmCi7n1|0ec85ac4a275aff3c464e139d40061aa0062a4e7376666b99ec8063a6715788a"
    },
    "_httpRequestRequestTime": 1687836456
  }
}