---
title: "GraphQLクエリ"
slug: "graphql-queries"
abstract: ""
---
# GraphQLクエリ

GraphQLは、長文・短文の両方でクエリを作成できます。

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

## SearchはIDの資産のために

以下のクエリは、特定のID(asset.alexander-mils-667996)を持つ*M\_Asset*エンティティタイプから単一の資産に関するデータを取得します。

{
 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 by definition

以下のクエリは*M\_Content*エンティティタイプからデータを取得し、各エンティティのidとcontent\_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 Email*、*Fruitful 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 &nbsp; /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;\\" &nbsp; /p p style=\\"text-align:center;\\" &nbsp; /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.&nbsp; /p figure class=\\"image\\" img srcset=\\"https://stylelabsdemo.com/api/public/content/99c986d065aa45fda3a692e0e27d3928?v=45b06955&amp;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 &nbsp; /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 &nbsp; /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;\\" &nbsp; /p p style=\\"text-align:center;\\" &nbsp; /p p &nbsp; /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 &nbsp; /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節を追加することで、ANDやORのような論理演算子や、次のような後置辞を含むカスタム基準に基づいて結果数を制限できます。

-   \_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ポフィックスを使って、指定されたフィールド内のフレーズを検索してください。このポステフィックスは単一のフィールドにのみ適用されます。

以下の例には、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 IDE](https://doc.sitecore.com/ch/ja/developers/cloud-dev/graphql-ide.html "GraphQL IDE")の「 **スキーマ** 」タブをクリックしてください。

ほとんどの演算子には、指定された条件に合わない値を探す逆バージョンが含まれています。例えば、fieldname\_not\_containsはfieldname\_containsの反対です。

## 全文検索

全文検索を行うには、where節のfulltextを使用します。containsポフィックスとは異なり、fulltextは関連するエンティティのすべてのフィールドおよび全文検索対象の先祖に関連する関連する特定の単語やフレーズを検索します。検索されるフィールドは[、Content Hubで](https://doc.sitecore.com/ch/en/users/content-hub/settings.html)全文プロパティとして設定されているものです。

以下の例は、任意の検索可能なフィールドで*M.Asset*に「 *fruitful lemon* 」というフレーズを問い合わせます。

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"
 }
 
 }
 }
}

## 論理演算子

文を組み合わせるためにANDやOR論理演算子を使い、クエリに高度な論理を組み込むことができます。

### および

AND演算子は2つの文を組み合わせるために使われます。クエリで返されるエンティティには、両方の文が真でなければなりません。

以下のクエリは *、M.Content*から返されます。内容名に*Healthy Mimosa*が含まれ、ブログの引用は *「Who wants a mimosa*」です。

{
 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つの文がその実体に対してほぼ真である必要があります。

以下のクエリは、コンテンツ名が *「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"
 }
 
 }
 }
}

### そして入れ子された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)は、仮想ブログタイプを用いて *M.Content*を検索し、タイトルに *Fruitful* が入り、本文が *null*でないブログを探します。結果はブログタイトルの昇順に並べます。
-   2つ目のクエリ(Email)は、 *M.Content*で仮想メールタイプを使い、タイトルに *Fruitful* があり、本文が *null*でないメールを探します。結果をメールタイプごとに昇順に並べます。

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": {
 "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:&nbsp; /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

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
 }
 }
 }
}

## hasNext

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
 }
 }
 }
}