Skip to content

[Docs] Add docs for unathenticated admin to main page #2241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@
}
]
},
{
"type": "Generic",
"anchorLink": "graphql-api-background",
"title": "Using the GraphQL API in background jobs",
"sectionContent": "You may need to interact with the Admin API when working outside of Shopify requests. To do so use the `unauthenticated.admin` function.\n\nThis enables apps to integrate with 3rd party services and perform background tasks.\n\n> Caution:\n> This function doesn't perform **any** validation and shouldn't rely on raw user input.\n\nWhen using this function, consider the following:\n\n#### Background tasks\n\nApps should ensure that the shop domain is authenticated when enqueueing jobs.\n\n#### 3rd party service requests\n\nApps must obtain the shop domain from the 3rd party service in a secure way.",
"codeblock": {
"title": "Make GraphQL requests in background jobs",
"tabs": [
{
"title": "/app/jobs/**/*.tsx",
"code": "// /background-jobs/**/*.ts\nimport { unauthenticated } from \"../shopify.server\";\n\n// Background job set up\n\nconst shop = 'mystore.myshopify.com'\nconst { admin } = await unauthenticated.admin(shop);\n\nconst response = await admin.graphql(\n `#graphql\n mutation populateProduct($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n }\n }\n }\n `,\n { variables: { input: { title: \"Product Name\" } } }\n);\n\nconst productData = await response.json();\n\n// Background job complete",
"language": "tsx"
}
]
},
"sectionCard": [
{
"url": "/docs/api/shopify-app-remix/unauthenticated/unauthenticated-admin",
"name": "Unauthenticated Admin",
"type": "tutorial"
}
]
},
{
"type": "Generic",
"anchorLink": "rest-api",
Expand Down
31 changes: 31 additions & 0 deletions packages/apps/shopify-app-remix/docs/staticPages/admin.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,37 @@ const data: LandingTemplateSchema = {
},
],
},
{
type: 'Generic',
anchorLink: 'graphql-api-background',
title: 'Using the GraphQL API in background jobs',
sectionContent: "You may need to interact with the Admin API when working outside of Shopify requests. To do so use the `unauthenticated.admin` function." +
"\n\nThis enables apps to integrate with 3rd party services and perform background tasks." +
"\n\n> Caution:" +
"\n> This function doesn't perform **any** validation and shouldn't rely on raw user input." +
"\n\nWhen using this function, consider the following:" +
"\n\n#### Background tasks" +
"\n\nApps should ensure that the shop domain is authenticated when enqueueing jobs." +
"\n\n#### 3rd party service requests" +
"\n\nApps must obtain the shop domain from the 3rd party service in a secure way.",
codeblock: {
title: 'Make GraphQL requests in background jobs',
tabs: [
{
title: '/app/jobs/**/*.tsx',
code: './examples/guides/admin/unauthenticated.example.tsx',
language: 'tsx',
},
],
},
sectionCard: [
{
url: '/docs/api/shopify-app-remix/unauthenticated/unauthenticated-admin',
name: 'Unauthenticated Admin',
type: 'tutorial',
},
],
},
{
type: 'Generic',
anchorLink: 'rest-api',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// /background-jobs/**/*.ts
import { unauthenticated } from "../shopify.server";

// Background job set up

const shop = 'mystore.myshopify.com'
const { admin } = await unauthenticated.admin(shop);

const response = await admin.graphql(
`#graphql
mutation populateProduct($input: ProductInput!) {
productCreate(input: $input) {
product {
id
}
}
}
`,
{ variables: { input: { title: "Product Name" } } }
);

const productData = await response.json();

// Background job complete
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const data: ReferenceEntityTemplateSchema = {
},
jsDocTypeExamples: [
'EmbeddedAdminContext',
'AdminApiContext',
'AdminApiContextWithoutRest',
'BillingContext',
'ScopesApiContext',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const data: ReferenceEntityTemplateSchema = {
type: 'AdminApiContext',
},
],
jsDocTypeExamples: ['AdminApiContext'],
jsDocTypeExamples: ['AdminApiContextWithoutRest'],
related: [
{
name: 'Authenticated context',
Expand Down