--- title: publication - GraphQL Admin description: Lookup a publication by ID. api_version: 2025-10 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/queries/publication md: https://shopify.dev/docs/api/admin-graphql/latest/queries/publication.md --- # publication query Lookup a publication by ID. ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID) required The ID of the Publication to return. *** ## Possible returns * Publication [Publication](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication) A publication is a group of products and collections that is published to an app. *** ## Examples * ### Retrieve a publication that doesn't exist #### Description Retrieving a publication by an ID that doesn't exist returns \`null\`. #### Query ```graphql query publication($id: ID!) { publication(id: $id) { name collections(first: 5) { edges { node { id title updatedAt } } } } } ``` #### Variables ```json { "id": "gid://shopify/Publication/-1" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/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" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { 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 json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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) ``` #### Node.js ```javascript 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" }, }, }); ``` #### Response ```json { "publication": null } ``` * ### Retrieve an existing publication #### Query ```graphql query publication($id: ID!) { publication(id: $id) { name collections(first: 5) { edges { node { id title updatedAt } } } } } ``` #### Variables ```json { "id": "gid://shopify/Publication/244171671" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/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/244171671" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { 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/244171671" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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/244171671" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript 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/244171671" }, }, }); ``` #### Response ```json { "publication": { "name": "Online Store", "collections": { "edges": [ { "node": { "id": "gid://shopify/Collection/79210309", "title": "Custom Other Items", "updatedAt": "2008-10-10T00:00:00Z" } }, { "node": { "id": "gid://shopify/Collection/94229130", "title": "All products more expensive than free", "updatedAt": "2006-02-02T00:00:00Z" } }, { "node": { "id": "gid://shopify/Collection/142458073", "title": "All snowboards", "updatedAt": "2006-02-02T00:00:00Z" } }, { "node": { "id": "gid://shopify/Collection/411960790", "title": "Bold snowboards", "updatedAt": "2006-02-02T00:00:00Z" } }, { "node": { "id": "gid://shopify/Collection/431528632", "title": "All arbor products tagged deepsnow", "updatedAt": "2006-02-02T00:00:00Z" } } ] } } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20publication\(%24id%3A%20ID!\)%20%7B%0A%20%20publication\(id%3A%20%24id\)%20%7B%0A%20%20%20%20name%0A%20%20%20%20collections\(first%3A%205\)%20%7B%0A%20%20%20%20%20%20edges%20%7B%0A%20%20%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20%20%20title%0A%20%20%20%20%20%20%20%20%20%20updatedAt%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22id%22%3A%20%22gid%3A%2F%2Fshopify%2FPublication%2F-1%22%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { 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 json = await response.json(); return json.data; } ``` ##### GQL ``` query publication($id: ID!) { publication(id: $id) { name collections(first: 5) { edges { node { id title updatedAt } } } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/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" } }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { 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 json = await response.json(); return json.data; } ``` ##### Node.js ``` 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" }, }, }); ``` ##### Ruby ``` 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 ```json { "id": "gid://shopify/Publication/-1" } ``` ## Response JSON ```json { "publication": null } ```