Anchor to publication
publication
query
Lookup a publication by ID.
Anchor to Arguments
Arguments
- •ID!required
The ID of the Publication to return.
Was this section helpful?
Anchor to Possible returnsPossible returns
- Anchor to PublicationPublication•
A publication is a group of products and collections that is published to an app.
Was this section helpful?
- Retrieve a publication that doesn't exist
- Retrieve an existing publication
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query publication($id: ID!) {
publication(id: $id) {
name
collections(first: 5) {
edges {
node {
id
title
updatedAt
}
}
}
}
}`,
{
variables: {
"id": "gid://shopify/Publication/-1"
},
},
);
const data = await response.json();
query publication($id: ID!) {
publication(id: $id) {
name
collections(first: 5) {
edges {
node {
id
title
updatedAt
}
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query publication($id: ID!) { publication(id: $id) { name collections(first: 5) { edges { node { id title updatedAt } } } } }",
"variables": {
"id": "gid://shopify/Publication/-1"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query publication($id: ID!) {
publication(id: $id) {
name
collections(first: 5) {
edges {
node {
id
title
updatedAt
}
}
}
}
}`,
{
variables: {
"id": "gid://shopify/Publication/-1"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query publication($id: ID!) {
publication(id: $id) {
name
collections(first: 5) {
edges {
node {
id
title
updatedAt
}
}
}
}
}`,
"variables": {
"id": "gid://shopify/Publication/-1"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query publication($id: ID!) {
publication(id: $id) {
name
collections(first: 5) {
edges {
node {
id
title
updatedAt
}
}
}
}
}
QUERY
variables = {
"id": "gid://shopify/Publication/-1"
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/Publication/-1"
}
Response
JSON{
"publication": null
}