Version: 2024-10
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collections(first: 5) { edges { node { id title handle updatedAt sortOrder } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collections(first: 5) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collections(first: 5) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<query([\"query\" => $query]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collections(first: 5) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n collections(first: 5) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n}"
input: null
response: { "data": { "collections": { "edges": [ { "node": { "id": "gid://shopify/Collection/79210309", "title": "Custom Other Items", "handle": "reorder_custom", "updatedAt": "2008-10-10T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/94229130", "title": "All products more expensive than free", "handle": "everything", "updatedAt": "2006-02-02T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/142458073", "title": "All snowboards", "handle": "snowboards", "updatedAt": "2006-02-02T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/411960790", "title": "Bold snowboards", "handle": "bold", "updatedAt": "2006-02-02T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/431528632", "title": "All arbor products tagged deepsnow", "handle": "all-arbor-products-tagged-deepsnow", "updatedAt": "2006-02-02T00:00:00Z", "sortOrder": "MANUAL" } } ] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collections(first: 5, query: \\\"collection_type:smart\\\", sortKey: UPDATED_AT, reverse: true) { edges { node { id title handle updatedAt sortOrder } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collections(first: 5, query: \"collection_type:smart\", sortKey: UPDATED_AT, reverse: true) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collections(first: 5, query: \"collection_type:smart\", sortKey: UPDATED_AT, reverse: true) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<query([\"query\" => $query]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collections(first: 5, query: \"collection_type:smart\", sortKey: UPDATED_AT, reverse: true) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n collections(first: 5, query: \"collection_type:smart\", sortKey: UPDATED_AT, reverse: true) {\n edges {\n node {\n id\n title\n handle\n updatedAt\n sortOrder\n }\n }\n }\n}"
input: null
response: { "data": { "collections": { "edges": [ { "node": { "id": "gid://shopify/Collection/522532842", "title": "Frisbees", "handle": "reorder_smart_frisbees", "updatedAt": "2008-10-12T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/1063001310", "title": "Smart Other items", "handle": "reorder_smart", "updatedAt": "2008-10-11T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/1009501285", "title": "Dummy", "handle": "blank", "updatedAt": "2006-02-02T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/925420914", "title": "All snowboards called Draft", "handle": "drafts", "updatedAt": "2006-02-02T00:00:00Z", "sortOrder": "MANUAL" } }, { "node": { "id": "gid://shopify/Collection/619119800", "title": "Cheap Stuff", "handle": "cheap", "updatedAt": "2006-02-02T00:00:00Z", "sortOrder": "MANUAL" } } ] } } }