1. GraphQL

GraphQLクエリ

日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

GraphQLでは、長い形式と短い形式の両方でクエリを作成できます。

メモ

デフォルトでは、GraphQLクエリは最初に見つかった10個の結果のみを返します。これを変更するには、first引数を使用します。Sitecore Content HubでのGraphQLクエリの構造と実装については、GraphQLの例を参照してください。

IDによるアセットのSearch

次のクエリは、特定のID (asset.alexander-mils-667996) を持つM_Assetエンティティタイプから1つのアセットに関するデータをフェッチします。

{ 
 m_Asset(id: "asset.alexander-mils-667996") {
  fileName
  title
  createdOn
 }
}

結果は次のとおりです。

{
 "data": {
  "m_Asset": {
   "fileName": "alexander-mils-667996.jpg",
   "title": "Elderflower cordial",
   "createdOn": "2022-11-03T04:27:34.000Z"
  }
 }
}

定義によるSearch

次のクエリは、M_Contentエンティティ型からデータをフェッチし、各エンティティのidcontent_Nameを返します。

{
 allM_Content {
  results {
   id
   content_Name
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "results": [
    {
     "id": "tTMVYivL2UyM3300lnraRQ",
     "content_Name": "Fruitful Summer (gb)"
    },
    {
     "id": "LB0MQmR3U0ST9NX2V4L_vA",
     "content_Name": "Fruitful Summer (es)"
    },
    {
     "id": "TmYSxnfrqUWL1-1VEL-ZdA",
     "content_Name": "Fruitful Summer (us)"
    },
    {
     "id": "Content.PowerofProtein",
     "content_Name": "The Power of Protein"
    },
    {
     "id": "Content.Snacking",
     "content_Name": "Snacking"
    },
    {
     "id": "Content.SalsaWithFruitChips",
     "content_Name": "Flavorful's famous salsa with Healthful fruit chips"
    }
   ]
  }
 }
}

インターフェイスから型を解決する

Interfaceは、インターフェイスを実装するために型に含める必要がある特定のフィールドのセットを含む抽象型です。これは、Content Hubで定義されたContentTypesエンティティでのみ使用できます。

次のクエリは、名前がFruitful EmailFruitful Blog、またはHealthy Mimosaを含むエンティティをM.Contentからフェッチします。

query contentEmailBlogInterface {
 allM_Content(
  where: {
   OR: [
    { content_Name_contains: "Fruitful Email" }
    { content_Name_contains: "Fruitful Blog" }
    { content_Name_contains: "Healthy Mimosa" }
   ]
  }
 ) {
  total
  results {
   content_Name
   ... on M_Content_Blog {
    blog_Title
    blog_Body
   }
   ... on M_Content_Email {
    email_Subject
    email_Body
   }
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 5,
   "results": [
    {
     "content_Name": "Fruitful Blog",
     "blog_Title": "Fruitful juices",
     "blog_Body": " figure class=\"image\" img width=\"150\" alt=\"Fruitful logo (black)\" src=\"https://stylelabsdemo.com/api/public/content/363909544a354d3b9a4549c306c88bbe?v=ad464f64\" /figure p br   /p p i strong Un tonto se cree sabio, pero un hombre sabio sabe que es un tonto. /strong /i /p figure class=\"image\" img width=\"200\" alt=\"Fruitful Orange mocktail\" src=\"https://stylelabsdemo.com/api/public/content/0268acbebdb643aa83d918ff8d03283d?v=f3607a38\" /figure p style=\"text-align:center;\"   /p p style=\"text-align:center;\"   /p p i strong Más valen tres horas adelantadas que un minuto tarde. /strong /i /p "
    },
    {
     "content_Name": "Fruitful Email (es-ES)",
     "email_Subject": "Fruitful juices",
     "email_Body": " figure class=\"image\" img width=\"150\" alt=\"Fruitful logo (inverted)\" src=\"https://stylelabsdemo.com/api/public/content/5b2a9683096b4543b997346c15bda790?v=b426739c\" /figure p i strong Los cobardes mueren muchas veces antes de su muerte; los valientes nunca sienten la muerte sino sólo una vez /strong /i /p figure class=\"image\" img width=\"380\" alt=\"Lime mocktail with lime slice\" src=\"https://stylelabsdemo.com/api/public/content/99c986d065aa45fda3a692e0e27d3928?v=45b06955\" /figure p i strong El infierno está vacío y todos los demonios están aquí. /strong /i /p "
    },
    {
     "content_Name": "Fruitful Email",
     "email_Subject": "Fruitful juices",
     "email_Body": " figure class=\"image\" img width=\"150\" src=\"https://stylelabsdemo.com/api/public/content/5b2a9683096b4543b997346c15bda790?v=b426739c\" alt=\"Fruitful logo (inverted)\" /figure p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum mattis, elementum velit maximus, mattis eros.  /p figure class=\"image\" img srcset=\"https://stylelabsdemo.com/api/public/content/99c986d065aa45fda3a692e0e27d3928?v=45b06955&t=w320 320w\" width=\"380\" src=\"https://stylelabsdemo.com/api/public/content/99c986d065aa45fda3a692e0e27d3928?v=45b06955\" alt=\"Lime mocktail with lime slice\" /figure p Etiam cursus viverra ante eu faucibus. Ut porttitor. /p p   /p "
    },
    {
     "content_Name": "Fruitful Blog",
     "blog_Title": "Fruitful juices",
     "blog_Body": " figure class=\"image\" img width=\"150\" src=\"https://stylelabsdemo.com/api/public/content/363909544a354d3b9a4549c306c88bbe?v=ad464f64\" alt=\"Fruitful logo (black)\" /figure p br   /p p Lorem ipsum dolor sit amet, consectetur adipiscing elit. /p figure class=\"image\" img width=\"200\" src=\"https://stylelabsdemo.com/api/public/content/0268acbebdb643aa83d918ff8d03283d?v=f3607a38\" alt=\"Fruitful Orange mocktail\" /figure p style=\"text-align:center;\"   /p p style=\"text-align:center;\"   /p p   /p "
    },
    {
     "content_Name": "Healthy Mimosa blog",
     "blog_Title": "Who wants a mimosa?!",
     "blog_Body": " p I do, always! Mimosas are supremely simple bubbly cocktails made with sparkling wine and orange juice. They're light, fizzy and easy to sip. /p p I love ordering mimosas at weekend brunch, and serving them to family and friends on holidays—Easter, Mother's Day, July 4th, Christmas, you name it. Mimosas liven up wedding showers and baby showers. I bring mimosa supplies to football watch parties, and no one complains. I've shared a few variations on mimosas over the years. Today, I'm going to share everything you've ever wanted to know about mimosas, plus a basic mimosa recipe and variations. If you haven't poured your first mimosa yet, you'll be a mimosa expert by the end of this post! If you're a seasoned mimosa drinker, I think you'll find some new tips here, too. /p p   /p p span class=\\\"text-big\\\" strong Mimosa Ingredients: /strong /span /p p Classic mimosas require just two ingredients: dry sparkling wine, and orange juice. Some recipes will tell you to add some other alcohol or orange liqueur. Don't listen to them! /p p strong Sparkling Wine /strong /p p The best Champagne for mimosas isn't actually Champagne. For mimosas, opt for less-expensive Cava or Prosecco. Cava is from Spain and Prosecco is from Italy, but they're both delicious dry sparkling wines that mix well with juice. Bonus? They're affordable. A good bottle of Cava or Prosecco will run about $12 to $16. Avoid super cheap sparkling wine, unless you want a headache with your mimosas. Don't waste your pricy bottle of Champagne on mimosas, since we're diluting those delicate notes with orange juice. /p p strong Orange Juice /strong /p p Cold, fresh orange juice is best for mimosas. If you're buying orange juice at the store, opt for high-quality such as the Fruitful Orange Juice! /p p strong Mimosa Ratio /strong /p p The perfect ratio of sparkling wine to orange juice is up to you. My suggestion? Start with the 50/50 ratio suggested below and adjust from there. I make my mimosas with 2 parts sparkling wine and 1 part orange juice—they're light, fizzy, and pack a punch. That's how we made them when I was a bartender. If you like sweeter, more juicy mimosas, start with a 50/50 ratio and add more orange juice if desired. After some delicious experimentation, you'll know exactly how you like your mimosas! /p "
    }
   ]
  }
 }
}

これらの結果には、コンテンツ名フィールド、仮想M_Content_Blogタイプのブログタイトルと本文フィールド、仮想M-Content_Emailタイプのメールの件名と本文フィールドが含まれます。このようなインクルードを要求するには、クエリでタイプの先頭に ... on Typeを付け、インターフェイスが返されたときにコンテンツ タイプの修飾子を作成します。

トータル

totalフィールドは、指定した条件に一致するエンティティの数を返します。

次の例では条件が指定されていないため、クエリはM.Content内のエンティティの合計数を返します。

{
 allM_Content {
  total
 }
}

結果には、合計23個のエンティティが表示されます。

{
 "data": {
  "allM_Content": {
   "total": 23
  }
 }
}

どこ

クエリにwhere句を追加すると、カスタム条件 ( ANDORなどの論理演算子や、次のような接尾辞を含む) に従って結果の数を制限できます。

  • _eq

  • _neq

  • contains

  • fulltext

等しい

次の例には、アセットtitleが特定のフレーズと等しくなければならないことを示すwhere句が含まれています。

query AssetTitle {
 allM_Asset(where: { title_eq: "Group selfie with drinks" }) {
  total
  results {
   fileName
   title
   fileSize
   isDraft
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Asset": {
   "total": 1,
   "results": [
    {
     "fileName": "videoblock-example3.mp4",
     "title": "Group selfie with drinks",
     "fileSize": 10.08,
     "isDraft": null
    }
   ]
  }
 }
}

等しくない

次の例には、アセットisDraftプロパティがnullでない値を持つ必要があることを指定するwhere句が含まれています。

query AssetDraftIsNotNull {
 allM_Asset(where: { isDraft_neq: null }) {
  total
  results {
   fileName
   fileSize
   isDraft
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Asset": {
   "total": 1,
   "results": [
    {
     "fileName": "videoblock-example3.mp4",
     "fileSize": 10.08,
     "isDraft": true
    }
   ]
  }
 }
}

含む

contains接尾辞を使用して、特定のフィールド内の語句を検索します。この接尾辞は1つのフィールドでのみ機能します。

次の例は、content_Nameプロパティに "Fruitful" という用語を含める必要があることを指定するwhere句が含まれています。

{
 allM_Content(where: { content_Name_contains: "Fruitful" }) {
  total
  results {
   content_Name
   m_Content_IsVariant
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 7,
   "results": [
    {
     "content_Name": "Sparkling Punch using Fruitful Orange",
     "m_Content_IsVariant": null
    },
    {
     "content_Name": "Fruitful Summer (us)",
     "m_Content_IsVariant": true
    },
    {
     "content_Name": "Fruitful Summer (gb)",
     "m_Content_IsVariant": true
    },
    {
     "content_Name": "Fruitful Summer (es)",
     "m_Content_IsVariant": null
    },
    {
     "content_Name": "Fruitful refreshing ginger lemonade",
     "m_Content_IsVariant": null
    },
    {
     "content_Name": "Fruitful Cocktails",
     "m_Content_IsVariant": null
    },
    {
     "content_Name": "Fruitful Mocktails",
     "m_Content_IsVariant": null
    }
   ]
  }
 }
}

演算子

contains接尾辞と一緒に使用できる演算子は他にもあります。

  • fieldname_in - 潜在的な値の定義されたリストに表示される値を確認します。

  • fieldname_startswith特定の文字列で始まる値を確認します。

  • fieldname_endswith特定の文字列で終わる値を確認します。

完全なリストを表示するには、GraphQL IDESchemaタブをクリックします。

ほとんどの演算子には、指定した条件に一致しない値を検索する反転バージョンが含まれています。たとえば、fieldname_not_containsfieldname_containsの反対です。

全文検索

where句でfulltextを使用して、全文検索を実行します。contains接尾辞とは異なり、fulltextは、関連するエンティティのすべてのフィールドと、全文検索用にマークされた祖先への適用可能な関係を、特定の単語または語句を検索します。検索されるフィールドは、Content Hubでフルテキスト プロパティとして構成されているフィールドです。

次の例では、検索可能なフィールドでfruitful lemonという語句をM.Assetにクエリします。

query {
 allM_Asset(where: {
  fulltext: "fruitful lemon"
 }) {
  results {
   title
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Asset": {
   "results": [
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9926"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9837"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9748"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9659"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9570"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9481"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9392"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9303"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9214"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9125"
    }
   ]
  }
 }
}

fulltextを他の接尾辞と組み合わせることができます。

query {
 allM_Asset(where: {
  fulltext: "Fruitful Lemon mocktail with dried lemon slices"
  title_contains: "92"
 }) {
  results {
   title
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Asset": {
   "results": [
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9926"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9392"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-9214"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-5921"
    },
    {
     "title": "Fruitful Lemon mocktail with dried lemon slices-492"
    }
   ]
  }
 }
}

注文順

orderByキーワードを使用して、結果セットを特定の順序で並べ替えます。

次のクエリは、レシピのタイトルで結果をソートします。 _DESCまたは _ASCを追加して、ソート順を降順または昇順に指定できます。

{
 allM_Content_Recipe(
  where: { recipe_Title_contains: "Fruitful" }
  orderBy: RECIPE_TITLE_ASC
 ) {
  total
  results {
   recipe_Title
   }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content_Recipe": {
   "total": 4,
   "results": [
    {
     "recipe_Title": "Fruitful mango mocktail"
    },
    {
     "recipe_Title": "Fruitful refreshing ginger lemonade as an alternative to soda"
    },
    {
     "recipe_Title": "Fruitful's famous salsa with Healthful fruit chips"
    },
    {
     "recipe_Title": "Sparkling Punch using Fruitful Orange"
    }
   ]
  }
 }
}

論理演算子

ANDORの論理演算子を使用してステートメントを結合し、クエリに高度なロジックを作成できます。

そして

AND演算子は、2つのステートメントを組み合わせるために使用されます。特定のエンティティがクエリによって返されるには、そのエンティティに対して両方のステートメントがtrueである必要があります。

次のクエリは、コンテンツ名にHealthy Mimosaが含まれ、ブログの引用がWho wants a mimosaされているM.Contentから結果を返します。

{
 allM_Content(
  where: {
   AND: [
    { content_Name_contains: "Healthy Mimosa" }
    { blog_Quote_neq: "Who wants a mimosa" }
   ]
  }
 ) {
  total
  results {
   content_Name
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 1,
   "results": [
    {
     "content_Name": "Healthy Mimosa blog"
    }
   ]
  }
 }
}

又は

OR演算子は、2つのステートメントを組み合わせるために使用されます。クエリによって返される特定のエンティティの場合、そのエンティティに対して少なくとも1つのステートメントがtrueである必要があります。

次のクエリは、コンテンツ名がThe Power of ProteinまたはHealthy Mimosaであるコンテンツを返します。

{
 allM_Content(
  where: {
   OR: [
    { content_Name_contains: "The Power of Protein" }
    { content_Name_contains: "Healthy Mimosa" }
   ]
  }
 ) {
  total
  results {
   content_Name
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 2,
   "results": [
    {
     "content_Name": "The Power of Protein"
    },
    {
     "content_Name": "Healthy Mimosa blog"
    }
   ]
  }
 }
}

ANDとネストされたOR

AND演算子とOR演算子をネストできます。

次のクエリは、summer savingsまたはFruitful refreshing ginger lemonadeという名前のコンテンツを検索します。

{
 allM_Content(
  where: {
   AND: [
    {
     OR: [
      { content_Name_eq: "Summer Savings" }
      { content_Name_eq: "Fruitful refreshing ginger lemonade" }
     ]
    }
    { m_Content_IsVariant_eq: false }
   ]
  }
 ) {
  total
  results {
   content_Name
   m_Content_IsVariant
   createdOn
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 3,
   "results": [
    {
     "content_Name": "Summer Savings",
     "m_Content_IsVariant": false,
     "createdOn": "2021-07-29T13:56:32.000Z"
    },
    {
     "content_Name": "Summer Savings",
     "m_Content_IsVariant": false,
     "createdOn": "2021-07-29T13:55:39.000Z"
    },
    {
     "content_Name": "Fruitful refreshing ginger lemonade",
     "m_Content_IsVariant": false,
     "createdOn": "2021-07-29T12:17:38.000Z"
    }
   ]
  }
 }
}

タイプ名

__typenameフィールドには、そのオブジェクトのGraphQLスキーマタイプの名前が含まれます。例えば:

query typeName {
 allM_Content(where: {content_Name_contains: "Mimosa"}) {
  total
  results{
   content_Name
   __typename
  }
 } 
}

複数のクエリの実行

1つの要求で複数のクエリを実行できます。クエリは互いに影響しません。次の例では、2つのクエリが同時に実行されています。

  • 最初のクエリ(Blog)は、仮想ブログタイプを使用して、タイトルにFruitfulが含まれ、本文がnullでないブログをM.Contentで検索します。結果はブログのタイトルの昇順で並べ替えられます。

  • 2番目のクエリ(Email)は、タイトルにFruitfulが含まれ、本文がnullでないメールを、仮想電子メール タイプを使用してM.Contentで検索します。結果はメールの種類ごとに昇順で並べ替えられます。

query contentEmailBlog {
 allM_Content_Blog(
  where: { blog_Title_contains: "Fruitful", blog_Body_neq: null }
  orderBy: BLOG_TITLE_ASC
 ) {
  total
  results {
   blog_Title
   blog_Body
   blog_Quote
  }
 }

 allM_Content_Email(
  where: { email_Subject_contains: "Fruitful", email_Body_neq: null }
  orderBy: EMAIL_SUBJECT_ASC
 ) {
  total
  results {
   email_Subject
   email_Body
  }
 }
}

これら2つのクエリの結果は、dataという名前の1つのオブジェクトにグループ化され、次のようになります。

{
 "data": {
  "blog": {
   "total": 3,
   "results": [
    {
     "blog_Title": "Fruitful blog",
     "blog_Body": " p There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain. There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain. There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain /p figure class=\"image\" img width=\"1100\" alt=\"Refreshing mocktails\" src=\"https://stylelabsdemo.com/api/public/content/2ed85585609c43bda24ae92372a5f311?v=f4d87d58\" /figure ",
     "blog_Quote": " p The strong fruit /strong of your own hard work is the sweetest. /p "
    },
    {
     "blog_Title": "Fruitful blog",
     "blog_Body": " p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pulvinar tellus non augue vestibulum vulputate. Proin non tortor vitae ante tincidunt dictum eget vitae tortor. /p figure class=\"image\" img width=\"1100\" alt=\"Refreshing mocktails\" src=\"https://stylelabsdemo.com/api/public/content/2ed85585609c43bda24ae92372a5f311?v=f4d87d58\" /figure ",
     "blog_Quote": " p br Le fruit de votre propre travail acharné est le plus doux. /p "
    },
    {
     "blog_Title": "Fruitful blog",
     "blog_Body": " p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pulvinar tellus non augue vestibulum vulputate. Proin non tortor vitae ante tincidunt dictum eget vitae tortor. /p figure class=\"image\" img width=\"1100\" alt=\"Refreshing mocktails\" src=\"https://stylelabsdemo.com/api/public/content/2ed85585609c43bda24ae92372a5f311?v=f4d87d58\" /figure ",
     "blog_Quote": " p br El fruto de tu propio trabajo duro es el más dulce. /p "
    }
   ]
  },
  "email": {
   "total": 1,
   "results": [
    {
     "email_Subject": "Fruitful Late Summer Email",
     "email_Body": " p br strong Fruitful:  /strong /p p No hay nadie que ame el dolor mismo, que lo busque y quiera tenerlo, simplemente porque es dolor. /p figure class=\"image\" img width=\"1100\" alt=\"Product layer 3\" src=\"https://stylelabsdemo.com/api/public/content/c8cc3c37df854f9c92c0ddef0795198d?v=0039f433\" /figure "
    }
   ]
  }
 }
}

カーソルベースのページネーション

カーソルベースのページネーションは、データセット内の特定の項目へのポインターを返します。後続の要求では、サーバーは指定されたポインターの後に結果を返します。

まずは

first引数は、クエリによって返される結果の数を制限します。この引数の値は1,000未満にする必要があります。デフォルト値は10です。次の例では、制限は2つの結果です。

query firstTwo {
 allM_Content(first:2) {
  total
  results {
   id 
   content_Name
   m_Content_IsVariant

  }
 }
}

first引数を指定しない場合、このクエリは28個のエントリを返します。first引数を2に設定すると、結果には最初に見つかった2つのエンティティのみが含まれます。

{
 "data": {
  "allM_Content": {
   "total": 28,
   "results": [
    {
     "id": "BDolxU3bGkWMwFJk-s8Idg",
     "content_Name": "Fruitful Summer (es-ES)",
     "m_Content_IsVariant": true
    },
    {
     "id": "igADXjecyk2oF4lo_tfs2Q",
     "content_Name": "Fruitful Summer (es-ES)",
     "m_Content_IsVariant": true
    }
   ]
  }
 }
}

ページ情報

pageInfoタイプには、ページネーションに必要な情報が含まれています。

エンドカーソル

endCursorフィールドは、現在のページの最後のエンティティに関連付けられたカーソルを表します。

手記

カーソルは不透明であり、クライアントによる操作を意図していません。

query endCursor {
 allM_Content(first: 5) {
  total
  results {
   id
   content_Name
   m_Content_IsVariant
  }
  pageInfo {
   endCursor
   hasNext
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 28,
   "results": [
    {
     "id": "BDolxU3bGkWMwFJk-s8Idg",
     "content_Name": "Fruitful Summer (es-ES)",
     "m_Content_IsVariant": true
    },
    {
     "id": "igADXjecyk2oF4lo_tfs2Q",
     "content_Name": "Fruitful Summer (es-ES)",
     "m_Content_IsVariant": true
    },
    {
     "id": "p70lTBrPSkqTZ2Ky3BdmWw",
     "content_Name": "Fruitful Summer (es-ES)",
     "m_Content_IsVariant": true
    },
    {
     "id": "9zjJfWK_UkSoX8Gd1I8dPg",
     "content_Name": "Fruitful Summer",
     "m_Content_IsVariant": null
    },
    {
     "id": "OwuHPqtSNk25OF6CPz6s8A",
     "content_Name": "Fruitful Juices",
     "m_Content_IsVariant": null
    }
   ],
   "pageInfo": {
    "endCursor": "eyJzZWFyY2hBZnRlciI6WyIxNjEzNzMyMDk1MTcyIl0sImNvdW50Ijo1fQ==",
    "hasNext": true
   }
  }
 }
}

has次へ

hasNextは、使用可能な結果がさらにあるかどうかを示すブール値です。

query hasNext {
 allM_Content(first: 2) {
  total
  results {
   id
   content_Name
   m_Content_IsVariant
  }
  pageInfo {
   hasNext
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 28,
   "results": [
    {
     "id": "BDolxU3bGkWMwFJk-s8Idg",
     "content_Name": "Fruitful Summer (es-ES)",
     "m_Content_IsVariant": true
    },
    {
     "id": "igADXjecyk2oF4lo_tfs2Q",
     "content_Name": "Fruitful Summer (es-ES)",
     "m_Content_IsVariant": true
    }
   ],
   "pageInfo": {
    "hasNext": true
   }
  }
 }
}
手記

hasNexttrueであるため、返されなかった結果がさらにあります。

afterパラメーターを使用すると、データセット全体の特定のポイントより後に発生した結果のみを返すことができます。このポイントは、endCursor引数を含むクエリを使用して取得できるカーソルを使用して決定されます。次のクエリでは、コンテンツ項目がeyJzZWFyY2hBZnRlciI6WyIxNjEzNzMyMDk1MTcyIl0sImNvdW50Ijo1fQ==.

query afterEndCursor {
 allM_Content(
  first: 5
  after: "eyJzZWFyY2hBZnRlciI6WyIxNjEzNzMyMDk1MTcyIl0sImNvdW50Ijo1fQ=="
 ) {
  total
  results {
   id
   content_Name
   m_Content_IsVariant
  }
  pageInfo {
   endCursor
   hasNext
  }
 }
}

結果は次のとおりです。

{
 "data": {
  "allM_Content": {
   "total": 28,
   "results": [
    {
     "id": "wT5RNeIcQ0SHTORNT1faug",
     "content_Name": "Fruitful Summer (it-IT)",
     "m_Content_IsVariant": true
    },
    {
     "id": "Content.SalsaWithFruitChips",
     "content_Name": "Flavorful's famous salsa with Healthful fruit chips",
     "m_Content_IsVariant": null
    },
    {
     "id": "Content.PowerofProtein",
     "content_Name": "The Power of Protein",
     "m_Content_IsVariant": null
    },
    {
     "id": "Content.PowerFromWithin",
     "content_Name": "Power comes from within",
     "m_Content_IsVariant": null
    },
    {
     "id": "Content.FruitfulGinger",
     "content_Name": "Fruitful refreshing ginger lemonade",
     "m_Content_IsVariant": null
    }
   ],
   "pageInfo": {
    "endCursor": "eyJzZWFyY2hBZnRlciI6WyIxNjEzMzY0Nzg0MTk4Il0sImNvdW50IjoxMH0=",
    "hasNext": true
   }
  }
 }
}
この記事を改善するための提案がある場合は、 お知らせください!