You can copy and paste each query to the Graphiql IDE
{
# Get first 10 publications
publications(namespaceId: 1, first:10) {
edges {
node {
publicationId
title
}
}
}
}
{
# Get first two publications with cursor
# First two publications
firstTwo: publications(namespaceId: 1, first:2) {
edges {
cursor
node {
publicationId
title
}
}
}
# Prints the second publication
secondOne: publications(namespaceId: 1, first:1, after:"MQ==") {
edges {
cursor
node {
publicationId
title
}
}
}
}
{
# Get the page by ID and by URL
byId: page(namespaceId: 1, publicationId: 5, pageId: 262) {
url
}
byUrl: page(namespaceId: 1, publicationId: 5, url: "/index.html") {
itemId
}
}
{
# Get pages by url
pages(namespaceId: 1, url: "/index.html") {
edges {
node {
title
url
}
}
}
}
{
# Get the binary component by ID and by URL
# Get binary component by Id with binary variants filtered by url
byId: binaryComponent(namespaceId: 1, publicationId: 5, binaryId: 287) {
title
multiMedia
variants(url: "/media/company-news-placeholder_tcm5-287.png") {
edges {
node {
binaryId
description
downloadUrl
path
url
}
}
}
}
# Get binary component that has any binary variant with specified url
byUrl: binaryComponent(namespaceId: 1, publicationId: 5, url: "/media/company-news-placeholder_tcm5-287.png") {
title
multiMedia
variants {
edges {
node {
binaryId
description
downloadUrl
path
url
}
}
}
}
}
{
# Get ComponentPresentation directly from COMPONENT_PRESENTATIONS table
componentPresentation(namespaceId: 1, publicationId: 5, componentId: 256, templateId: 123) {
title
rawContent {
data
}
component {
itemId
}
componentTemplate {
itemId
}
}
}
{
# Get contained ComponentPresentation's
# Note that such ComponentPresentation's are a combination of a component and template linked to the page through LINK_INFO table
# Such combinations may not exist in COMPONENT_PRESENTATIONS table and you can not use GQL 'componentPresentation'
# query to fetch them directly.
page(namespaceId: 1, publicationId: 5, pageId: 272) {
url
title
containerItems {
... on ComponentPresentation {
component {
itemId
title
}
componentTemplate {
itemId
}
}
}
}
}
Note that for containerItems we are supporting only ComponentPresentation type right now!
{
# Narrows down Component to specific types.
# In response you can see that each entry has publicationId,
# however namespaceId available only for BinaryComponent, and id fetched only for Component
# ContentComponent is an interface, however Component and BinaryComponent are objects.
# BinaryComponent is multimedia component.
page(namespaceId: 1, publicationId: 5, pageId: 272) {
url
title
containerItems {
... on ComponentPresentation {
component {
multiMedia
... on ContentComponent {
publicationId
}
... on Component {
id
}
... on BinaryComponent {
namespaceId
}
}
}
}
}
}
{
# Get first category and its children keywords
categories(namespaceId: 1, publicationId: 5, first: 1) {
edges {
node {
taxonomyType
taxonomyId
itemId
itemType
children {
edges {
node {
taxonomyType
taxonomyId
itemId
itemType
}
}
}
}
}
}
}
{
# Get keyword by ID
keyword(namespaceId: 1, publicationId: 5, categoryId: 17, keywordId: 77) {
itemId
name
}
}
{
# Get keywords and structure groups related to the page, find parents and expand children
# You can see structure group in response as it was deployed to ITEM_CATEGORIES_AND_KEYWORDS table,
# but you can not query it directly using 'structureGroup' query as this SG is absent in TAXFACETS
page(namespaceId: 1, publicationId: 5, pageId: 272) {
url
title
taxonomies {
... on StructureGroup {
itemId
itemType
taxonomyId
taxonomyType
key
title
}
... on Keyword {
itemId
itemType
taxonomyId
taxonomyType
key
title
parent {
itemId
itemType
taxonomyId
taxonomyType
key
title
children {
edges {
node {
itemId
itemType
taxonomyId
taxonomyType
key
title
}
}
}
}
}
}
}
}