GraphQL の例
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
以下は、GraphQL クエリの例です。
Fruitful を含むレシピ タイトルをクエリする
レシピ タイトルに Fruitful が含まれる場合、recipe_Title_contains: "Fruitful"
を使用してクエリします。
リクエスト本文
query RecipeFruitful {
allM_Content(where: { recipe_Title_contains: "Fruitful" }) {
total
results {
content_Name
__typename
}
}
}
応答
{
"data": {
"allM_Content": {
"total": 3,
"results": [
{
"content_Name": "Fruitful refreshing ginger lemonade",
"__typename": "M_Content_Recipe"
},
{
"content_Name": "Sparkling Punch using Fruitful Orange",
"__typename": "M_Content_Recipe"
},
{
"content_Name": "Fruitful Mocktails",
"__typename": "M_Content_Recipe"
}
]
}
}
}
特定の分類のコンテンツ アイテムをクエリする
特定の分類についてコンテンツ アイテムをクエリすると、ブログの総数とともに、すべてのブログのタイトルと引用が表示されます。
リクエスト本文
query getAllBlogs {
allM_Content_Blog {
total
results {
blog_Title
blog_Quote
}
}
}
応答
{
"data": {
"allM_Content_Blog": {
"total": 6,
"results": [
{
"blog_Title": "Who wants a mimosa!",
"blog_Quote": "<p>Sometimes I put a splash of orange juice in my champagne.</p>"
},
{
"blog_Title": "Nutrition tips blog post",
"blog_Quote": null
},
{
"blog_Title": "Kracht komt van binnenuit",
"blog_Quote": null
},
{
"blog_Title": "Power comes from within",
"blog_Quote": null
},
{
"blog_Title": "Healthful nutrition helps you develop your diet",
"blog_Quote": null
},
{
"blog_Title": "Health Is Happiness",
"blog_Quote": null
}
]
}
}
}
特定のコンテンツ コレクション内のコンテンツ アイテムをクエリする
id_eq
を使用してコンテンツ アイテムをクエリします。
リクエスト本文
query getContentInContentCollection {
allM_ContentCollection(where: { id_eq: "Ai-JNhneM024pMItfBeYJQ" }) {
total
results {
id
contentCollectionName
contentCollectionToContent {
__typename
total
results {
content_Name
__typename
}
}
}
}
}
応答
{
"data": {
"allM_ContentCollection": {
"total": 1,
"results": [
{
"id": "Ai-JNhneM024pMItfBeYJQ",
"contentCollectionName": "Fruitful",
"contentCollectionToContent": {
"__typename": "M_ContentList",
"total": 4,
"results": [
{
"content_Name": "Healthy Mimosa blog",
"__typename": "M_Content_Blog"
},
{
"content_Name": "Healthful is the latest Flavorful Brand",
"__typename": "M_Content_Email"
},
{
"content_Name": "Sparkling Punch using Fruitful Orange",
"__typename": "M_Content_Recipe"
},
{
"content_Name": "Power comes from within",
"__typename": "M_Content_Blog"
}
]
}
}
]
}
}
}
en-US のローカリゼーションを持つすべての変数をクエリする
元のコンテンツ (m_Content_IsVariant_eq: true
) の変数であるすべてのコンテンツと、en-US(m_Localization_ids: "M.Localization.en-US"
) のローカリゼーションを持つコンテンツをクエリします。
リクエスト本文
query variantIsEnUS {
allM_Content(
where: {
m_Content_IsVariant_eq: true
localizationToContent: { m_Localization_ids: "M.Localization.en-US" }
}
) {
total
results {
id
content_Name
m_Content_IsVariant
localizationToContent {
valueName
}
}
}
}
応答
{
"data": {
"allM_Content": {
"total": 1,
"results": [
{
"id": "iAzTTLtsoEmuGKqBxPuAVg",
"content_Name": "Fruitful Summer 2021 (en-US)",
"m_Content_IsVariant": true,
"localizationToContent": {
"valueName": "en-US"
}
}
]
}
}
}
キャンペーン内のエンティティからすべての変数をクエリする
キャンペーン ID とブール値 m_Content_IsVariant_eq: true
を使用して、キャンペーン内のエンティティからすべての変数をクエリし、変数を表示します。
リクエスト本文
query campaignVariant {
allM_Content(
where: {
campaignToContent: { m_CMP_Campaign_ids: "M.CMP.Campaign.Summer2018" }
m_Content_IsVariant_eq: true
}
) {
total
results {
id
content_Name
m_Content_IsVariant
}
}
}
応答
{
"data": {
"allM_Content": {
"total": 2,
"results": [
{
"id": "wT5RNeIcQ0SHTORNT1faug",
"content_Name": "Fruitful Summer (it-IT)",
"m_Content_IsVariant": true
},
{
"id": "BDolxU3bGkWMwFJk-s8Idg",
"content_Name": "Fruitful Summer (es-ES)",
"m_Content_IsVariant": true
}
]
}
}
}
コンテンツ エンティティのすべての変数をクエリする
親コンテンツ ID と contentToContentVariant_Children
フィールドを使用してコンテンツ エンティティのすべての変数をクエリし、変数を表示します。
リクエスト本文
query allVariantsOfContent {
m_Content(id: "pBxKLsZaQU21-CTu9y0bWw") {
contentToContentVariant_Children {
results {
id
content_Name
__typename
localizationToContent {
valueName
}
}
}
}
}
応答
{
"data": {
"m_Content": {
"contentToContentVariant_Children": {
"results": [
{
"id": "bb_RjQxMS0O9ziQG7EWuog",
"content_Name": "Fruitful Summer (de-DE)",
"__typename": "M_Content_Email",
"localizationToContent": {
"valueName": "de-DE"
}
},
{
"id": "ah1bserorU-CIcDjFb5p-g",
"content_Name": "Fruitful Summer 2021 (en-GB)",
"__typename": "M_Content_Email",
"localizationToContent": {
"valueName": "en-GB"
}
},
{
"id": "iAzTTLtsoEmuGKqBxPuAVg",
"content_Name": "Fruitful Summer 2021 (en-US)",
"__typename": "M_Content_Email",
"localizationToContent": {
"valueName": "en-US"
}
}
]
}
}
}
}
プレビューでドラフト コンテンツ アイテムをクエリする
m_Content_IsDraft_eq: true
を使用して、プレビューでドラフト コンテンツ アイテムをクエリします。
リクエスト本文
query draftContentPreview {
allM_Content(where: { m_Content_IsDraft_eq: true }) {
total
results {
id
content_Name
m_Content_IsDraft
}
}
}
応答
{
"data": {
"allM_Content": {
"total": 2,
"results": [
{
"id": "Content.WakeUp",
"content_Name": "Everyone Wake Up",
"m_Content_IsDraft": true
},
{
"id": "Content.DevelopingADiet",
"content_Name": "Developing a diet",
"m_Content_IsDraft": true
}
]
}
}
}
複数のバージョンがあるコンテンツをクエリする
content_NumberOfCreatedVersions_gt: 1
を使用して、複数のバージョンがあるコンテンツをクエリします。
リクエスト本文
query moreThanOneVersionContent {
allM_Content(where: { content_NumberOfCreatedVersions_gt: 1 }) {
total
results {
id
content_Name
m_Content_IsDraft
content_NumberOfCreatedVersions
content_ApprovedForCreation
}
}
}
応答
{
"data": {
"allM_Content": {
"total": 1,
"results": [
{
"id": "Content.FruitfulGinger",
"content_Name": "Fruitful refreshing ginger lemonade",
"m_Content_IsDraft": false,
"content_NumberOfCreatedVersions": 3,
"content_ApprovedForCreation": null
}
]
}
}
}
コンテンツの型に基づいて条件付きメタデータをクエリする
インターフェイスを使用してサブクエリを作成し、コンテンツの型に基づいて条件付きメタデータをクエリします。
リクエスト本文
query draftConteintInPreview {
allM_Content(where: { m_Content_IsDraft_eq: true }) {
total
results {
id
content_Name
...on M_Content_Blog {
blog_Title
blog_Body
}
...on M_Content_Recipe {
recipe_Title
recipe_Ingredients
}
}
}
}
応答
{
"data": {
"allM_Content": {
"total": 2,
"results": [
{
"id": "t0uouuAwqkCYDo6Cfrub3w",
"content_Name": "Summer Mimosa",
"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><figure class=\"image\"><img srcset=\"https://stylelabsdemo.com/api/public/content/17d2484d681844c29780547185d53ffd?v=2d1e5a46&t=w320 320w, https://stylelabsdemo.com/api/public/content/17d2484d681844c29780547185d53ffd?v=2d1e5a46&t=w480 480w\" width=\"664\" src=\"https://stylelabsdemo.com/api/public/content/17d2484d681844c29780547185d53ffd?v=2d1e5a46\" alt=\"Mimosa cocktails\"></figure><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><strong>Mimosa Ingredients:</strong></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>"
},
{
"id": "-CVRo6Z7Y02yXEH_rS6y7w",
"content_Name": "Fruitful refreshing ginger lemonade",
"recipe_Title": "Fruitful refreshing ginger lemonade as an alternative to soda",
"recipe_Ingredients": "<p>Ingredients</p><p>3 cups white sugar<br>4 quarts water<br>14 slices fresh ginger root<br>4 cups fresh lemon juice<br>2 lemons, sliced</p>"
}
]
}
}
}
特定のアセットの url および相対 url をクエリする
パブリック リンクのマップを出力する urls
および相対 url は、relativeUrl
を使用してクエリします。
リクエスト本文
query AssetPublicLinks {
m_Asset(id: "asset.toa-heftiba-271805") {
fileName
id
urls
assetToPublicLink {
results {
id
status
relativeUrl
resource
expirationDate
}
}
}{
"data": {
"m_Asset": {
"fileName": "toa-heftiba-271805.jpg",
"id": "asset.toa-heftiba-271805",
"urls": {
"41af2ea3af5c492696fa8f1767ee35de": {
"url": "https://sitecore-test-staging.cloud/api/public/content/41af2ea3af5c492696fa8f1767ee35de?v=9746edf0",
"expiredOn": null,
"resource": "downloadOriginal",
"metadata": {
"filesize": 1.1,
"filesizebytes": "1101428",
"filename": "toa-heftiba-271805.jpg",
"width": "3936",
"height": "2624",
"group": "Images",
"extension": "jpg",
"content_type": "image/jpeg",
"resolution": "3936 2624",
"colorspace": "RGB ",
"megapixels": "10.328064"
}
},
"1ed0813750e348bb82636585d3769fe1": {
"url": "https://sitecore-test-staging.cloud/api/public/content/1ed0813750e348bb82636585d3769fe1?v=4b3ceca5",
"expiredOn": null,
"resource": "preview",
"metadata": {
"width": "1100",
"height": "733",
"content_type": "image/jpeg",
"filesizebytes": "68885"
}
}
},
"assetToPublicLink": {
"results": [
{
"id": "3TErg0azPESlGSMa8tVLKg",
"status": "Completed",
"relativeUrl": "41af2ea3af5c492696fa8f1767ee35de",
"resource": "downloadOriginal",
"expirationDate": null
},
{
"id": "or9hi1PLn0aXqnxQ8npr3w",
"status": "Completed",
"relativeUrl": "1ed0813750e348bb82636585d3769fe1",
"resource": "preview",
"expirationDate": null
}
]
}
}
}
}
応答
{
"data": {
"m_Asset": {
"fileName": "toa-heftiba-271805.jpg",
"id": "asset.toa-heftiba-271805",
"urls": {
"4f4e0ccfab8642009fe9ef321bdaa970": {
"url": "https://sitecore-test-staging.cloud/api/public/content/4f4e0ccfab8642009fe9ef321bdaa970?v=df2e3a60",
"expiredOn": null,
"resource": "downloadOriginal",
"metadata": {
"filesize": 1.1,
"filesizebytes": "1101428",
"filename": "toa-heftiba-271805.jpg",
"width": "3936",
"height": "2624",
"group": "Images",
"extension": "jpg",
"content_type": "image/jpeg",
"resolution": "3936 2624",
"colorspace": "RGB ",
"megapixels": "10.328064"
}
},
"3a497bc29c5741d985839e26cb198422": {
"url": "https://sitecore-test-staging.cloud/api/public/content/3a497bc29c5741d985839e26cb198422?v=0f28452c",
"expiredOn": null,
"resource": "preview",
"metadata": {
"width": "1100",
"height": "733",
"content_type": "image/jpeg",
"filesizebytes": "68885"
}
}
},
"assetToPublicLink": {
"results": [
{
"id": "AKxo6TjtQkKHCjQwNvKlSA",
"status": "Completed",
"relativeUrl": "3a497bc29c5741d985839e26cb198422",
"resource": "preview",
"expirationDate": null
},
{
"id": "nzxMRalDaUeDN0ZThInemg",
"status": "Completed",
"relativeUrl": "4f4e0ccfab8642009fe9ef321bdaa970",
"resource": "downloadOriginal",
"expirationDate": null
}
]
}
}
}
}
すべてのアセットをクエリして、関連するパブリック リンクを表示する
allM_Asset
を使用してすべてのアセットをクエリし、urls
を使用して各アセットのパブリック リンクを表示します。
リクエスト本文
{
allM_Asset {
results {
id
urls
}
}
}
応答
{
"data": {
"allM_Asset": {
"results": [
{
"id": "asset.oatmeal.jpg",
"urls": {
"oatmeal": {
"url": "https://sitecore-test-staging.cloud/api/public/content/oatmeal?v=c498d245",
"expiredOn": null,
"resource": "downloadOriginal",
"metadata": {
"filesize": 0.18,
"filesizebytes": "180019",
"filename": "oatmeal.jpg",
"width": "1500",
"height": "575",
"group": "Images",
"extension": "jpg",
"content_type": "image/jpeg",
"resolution": "1500 575",
"colorspace": "sRGB",
"megapixels": "0.8625"
}
}
}
},
{
"id": "asset.fruitful-product-line",
"urls": {}
},
{
"id": "asset.fruitful-hero2",
"urls": {}
},
{
"id": "asset.sara-dubler-769470",
"urls": {
"summersalad": {
"url": "https://sitecore-test-staging.cloud/api/public/content/summersalad?v=78f938b8",
"expiredOn": null,
"resource": "downloadOriginal",
"metadata": {
"filesize": 2.03,
"filesizebytes": "2033543",
"filename": "sara-dubler-769470.jpg",
"width": "3456",
"height": "2304",
"group": "Images",
"extension": "jpg",
"content_type": "image/jpeg",
"resolution": "3456 2304",
"colorspace": "RGB ",
"megapixels": "7.962624"
}
}
}
},
{
"id": "asset.logo-healthful.ai",
"urls": {}
},
{
"id": "asset.fruitful-presentation",
"urls": {
"cf17f452bab44781bd2648f3b08c4083": {
"url": "https://sitecore-test-staging.cloud/api/public/content/cf17f452bab44781bd2648f3b08c4083?v=22521590",
"expiredOn": null,
"resource": "downloadOriginal",
"metadata": {
"filesize": 0.78,
"filesizebytes": "776473",
"filename": "fruitful-presentation-v1.png",
"width": "1920",
"height": "1080",
"group": "Vectors",
"extension": "png",
"content_type": "image/png",
"resolution": "1920 1080",
"colorspace": "RGB ",
"megapixels": "2.0736",
"creator": "Adobe Photoshop CC 2018 (Macintosh)"
}
},
"39d8dd7ae68b4197a501179c8496eae6": {
"url": "https://sitecore-test-staging.cloud/api/public/content/39d8dd7ae68b4197a501179c8496eae6?v=dd800038",
"expiredOn": null,
"resource": "preview",
"metadata": {
"width": "1100",
"height": "619",
"content_type": "image/png",
"filesizebytes": "285321"
}
}
}
}
]
}
}
}