📈

【Shopify.dev和訳】AdminAPI/GraphQL reference/Access

2021/10/01に公開

この記事について

この記事は、Access APIの記事を和訳したものです。

記事内で使用する画像は、公式ドキュメント内の画像を引用して使用させていただいております。

Shopify アプリのご紹介

Shopify アプリである、「商品ページ発売予告アプリ | リテリア Coming Soon」は、商品ページを買えない状態のまま、発売日時の予告をすることができるアプリです。Shopify で Coming Soon 機能を実現することができます。

https://apps.shopify.com/shopify-application-314?locale=ja&from=daniel

Shopify アプリである、「らくらく日本語フォント設定|リテリア Font Picker」は、ノーコードで日本語フォントを使用できるアプリです。日本語フォントを導入することでブランドを演出することができます。

https://apps.shopify.com/font-picker-1?locale=ja&from=daniel

Access APIs

マーチャントから付与されたアクセス権を確認・管理することができます。

このセクションには次の内容が含まれています。

  • AccessScope - マーチャントのショップに適用されるアクセススコープのパーミッションを表します (read_orders など)。
  • StorefrontAccessToken - 認証されていない Storefront API にアクセスする必要があるクライアントに、認証されていないアクセス スコープを委任するために使用されるトークンです。
  • StorefrontAccessTokenDeleteInput - Storefront アクセストークンを削除するための入力フィールドを指定します。
  • StorefrontAccessTokenInput - ストアフロント アクセストークンの入力フィールドを指定します。
  • storefrontAccessTokenCreate - ストアフロント アクセストークンを作成します。
  • storefrontAccessTokenDelete - ストアフロントのアクセストークンを削除します。

オブジェクト

以下、Access のオブジェクトです。

AccessScope

マーチャントのショップに適用されるアクセススコープのパーミッション(read_ordersなど)を表します。

フィールド

descriptionString!
API 権限で有効になっているアクセススコープの説明。

handleString!
アクセススコープを表す人が読む用の文字列

AccessScope を返すタイプ

StorefrontAccessToken

認証されていない Storefront API にアクセスする必要のあるクライアントに、認証されていないアクセス・スコープを委任するために使用されるトークンです。

フィールド

accessScopesAccessScope!
トークンに関連するパーミッションのリスト。

accessTokenString!
発行されたパブリックアクセストークン

createdAtDateTime!
パブリックアクセストークンが作成された日付と時間。

idID!
グローバルに一意な識別子です。

titleString!
開発者が決定した各トークンの任意のタイトルで、参照目的で使用されます。

updatedAtDateTime!
ストアフロントアクセストークンが更新された日時です。

StorefrontAccessToken が返す型

StorefrontAccessToken のミューテーション

storefrontAccessTokenCreate
ストアフロント・アクセストークンを作成します。

storefrontAccessTokenDelete
ストアフロント・アクセストークンを削除します。

Implements

サンプル

# Get the title of the first 10 storefront access tokens
{
  shop {
    storefrontAccessTokens(first: 10) {
      edges {
        node {
          id
          title
        }
      }
    }
  }
}

以下のデータが返却されます。

{
  "data": {
    "shop": {
      "storefrontAccessTokens": {
        "edges": [
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56281661462",
              "title": "App"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56296636438",
              "title": "Test Storefront token"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56296669206",
              "title": "Test Storefront token"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385306646",
              "title": "placeholder"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385339414",
              "title": "placeholder"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385372182",
              "title": "placeholder"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385404950",
              "title": "placeholder"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385634326",
              "title": "placeholder"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385667094",
              "title": "placeholder"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385699862",
              "title": "placeholder"
            }
          }
        ]
      }
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 13,
      "actualQueryCost": 13,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 987,
        "restoreRate": 50
      }
    }
  }
}
# Get when the first 10 storefront access tokens were created and updated
{
  shop {
    storefrontAccessTokens(first: 10) {
      edges {
        node {
          id
          createdAt
          updatedAt
        }
      }
    }
  }
}

以下のデータが返却されます。

{
  "data": {
    "shop": {
      "storefrontAccessTokens": {
        "edges": [
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56281661462",
              "createdAt": "2021-04-14T16:26:49Z",
              "updatedAt": "2021-04-14T16:26:49Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56296636438",
              "createdAt": "2021-04-24T00:55:09Z",
              "updatedAt": "2021-04-24T00:55:09Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56296669206",
              "createdAt": "2021-04-24T00:55:51Z",
              "updatedAt": "2021-04-24T00:55:51Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385306646",
              "createdAt": "2021-06-12T20:44:49Z",
              "updatedAt": "2021-06-12T20:44:49Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385339414",
              "createdAt": "2021-06-12T20:46:12Z",
              "updatedAt": "2021-06-12T20:46:12Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385372182",
              "createdAt": "2021-06-12T20:46:25Z",
              "updatedAt": "2021-06-12T20:46:25Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385404950",
              "createdAt": "2021-06-12T20:56:28Z",
              "updatedAt": "2021-06-12T20:56:28Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385634326",
              "createdAt": "2021-06-13T12:05:04Z",
              "updatedAt": "2021-06-13T12:05:04Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385667094",
              "createdAt": "2021-06-13T12:05:16Z",
              "updatedAt": "2021-06-13T12:05:16Z"
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56385699862",
              "createdAt": "2021-06-13T12:06:35Z",
              "updatedAt": "2021-06-13T12:06:35Z"
            }
          }
        ]
      }
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 13,
      "actualQueryCost": 13,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 987,
        "restoreRate": 50
      }
    }
  }
}
# Get the access scopes for the first 10 storefront access tokens
{
  shop {
    storefrontAccessTokens(first: 2) {
      edges {
        node {
          id
          accessScopes {
            handle
          }
        }
      }
    }
  }
}

以下のデータが返却されます。

{
  "data": {
    "shop": {
      "storefrontAccessTokens": {
        "edges": [
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56281661462",
              "accessScopes": [
                {
                  "handle": "unauthenticated_read_content"
                },
                {
                  "handle": "unauthenticated_read_customer_tags"
                },
                {
                  "handle": "unauthenticated_read_product_tags"
                },
                {
                  "handle": "unauthenticated_read_product_inventory"
                },
                {
                  "handle": "unauthenticated_read_product_listings"
                },
                {
                  "handle": "unauthenticated_write_checkouts"
                },
                {
                  "handle": "unauthenticated_read_checkouts"
                },
                {
                  "handle": "unauthenticated_write_customers"
                },
                {
                  "handle": "unauthenticated_read_customers"
                }
              ]
            }
          },
          {
            "node": {
              "id": "gid://shopify/StorefrontAccessToken/56296636438",
              "accessScopes": [
                {
                  "handle": "unauthenticated_read_content"
                },
                {
                  "handle": "unauthenticated_read_customer_tags"
                },
                {
                  "handle": "unauthenticated_read_product_tags"
                },
                {
                  "handle": "unauthenticated_read_product_inventory"
                },
                {
                  "handle": "unauthenticated_read_product_listings"
                },
                {
                  "handle": "unauthenticated_write_checkouts"
                },
                {
                  "handle": "unauthenticated_read_checkouts"
                },
                {
                  "handle": "unauthenticated_write_customers"
                },
                {
                  "handle": "unauthenticated_read_customers"
                }
              ]
            }
          }
        ]
      }
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 7,
      "actualQueryCost": 7,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 993,
        "restoreRate": 50
      }
    }
  }
}

Mutation

storefrontAccessTokenCreate mutation

ストアフロントアクセストークンを作成します。

インタラクティブな例

これは、ミューテーションクエリの例です。

mutation storefrontAccessTokenCreate($input: StorefrontAccessTokenInput!) {
  storefrontAccessTokenCreate(input: $input) {
    shop {
      id
    }
    storefrontAccessToken {
      id
    }
    userErrors {
      field
      message
    }
  }
}

Variables

{
  "input": {
    "title": "placeholder"
  }
}

Arguments

引数 詳細
input(StorefrontAccessTokenInput!)required ストアフロントアクセストークンを作成するための入力フィールドを提供します

StorefrontAccessTokenInput フィールド

titleString!) required
ストアフロントアクセストークンのタイトル。

返却フィールド

shopShop!
ユーザーのショップです。

storefrontAccessTokenStorefrontAccessToken
ストアフロントのアクセストークンです。

userErrors([UserError!]!)
ミューテーションを実行した際に発生したエラーのリストです。

storefrontAccessTokenDelete mutation

ストアフロントのアクセストークンを削除します。

インタラクティブな例

これは、ミューテーションクエリの例です。

mutation storefrontAccessTokenDelete($input: StorefrontAccessTokenDeleteInput!) {
  storefrontAccessTokenDelete(input: $input) {
    deletedStorefrontAccessTokenId
    userErrors {
      field
      message
    }
  }
}

Variables

{
  "input": {
    "id": "Z2lkOi8vU2hvcGlmeS9FeGFtcGxlLzE="
  }
}

引数

引数 詳細
input(StorefrontAccessTokenDeleteInput!)required ストアフロントアクセストークンを削除するために必要な入力フィールドを提供します

StorefrontAccessTokenDeleteInput フィールド

idID!required
削除するストアフロントアクセストークンの ID です。

返却フィールド

deletedStorefrontAccessTokenIdID
削除されたストアフロント アクセストークンの ID です。

userError ([UserError!]!)
ミューテーションを実行して発生したエラーのリストです。

INPUTS

StorefrontAccessTokenDeleteInput input object

ストアフロントアクセストークンを削除するための入力フィールドを指定します。

Input fields

idID!required
削除するストアフロントアクセストークンの ID です。

StorefrontAccessTokenInput input object

ストアフロントアクセストークンの入力フィールドを指定します。

Input fields

titleString!required
ストアフロントアクセストークンのタイトル。

Shopify アプリのご紹介

Shopify アプリである、「商品ページ発売予告アプリ | リテリア Coming Soon」は、商品ページを買えない状態のまま、発売日時の予告をすることができるアプリです。Shopify で Coming Soon 機能を実現することができます。

https://apps.shopify.com/shopify-application-314?locale=ja&from=daniel

Shopify アプリである、「らくらく日本語フォント設定|リテリア Font Picker」は、ノーコードで日本語フォントを使用できるアプリです。日本語フォントを導入することでブランドを演出することができます。

https://apps.shopify.com/font-picker-1?locale=ja&from=daniel

Discussion

ログインするとコメントできます