From c75e4adf64a9dac020fe03eb308ba1aba2f7bb14 Mon Sep 17 00:00:00 2001 From: Elizabeth Kenyon Date: Mon, 5 Feb 2024 11:25:23 -0600 Subject: [PATCH] fix lint error --- packages/.prettierrc | 1 + .../docs/generated/generated_docs_data.json | 40 +++++++-------- .../shopify-app-remix/src/server/types.ts | 8 +-- .../src/server/unauthenticated/admin/types.ts | 50 +++++++++++-------- 4 files changed, 54 insertions(+), 45 deletions(-) create mode 100644 packages/.prettierrc diff --git a/packages/.prettierrc b/packages/.prettierrc new file mode 100644 index 0000000000..12e07afc1d --- /dev/null +++ b/packages/.prettierrc @@ -0,0 +1 @@ +"@shopify/prettier-config" diff --git a/packages/shopify-app-remix/docs/generated/generated_docs_data.json b/packages/shopify-app-remix/docs/generated/generated_docs_data.json index 1fea185ebf..e0283d818f 100644 --- a/packages/shopify-app-remix/docs/generated/generated_docs_data.json +++ b/packages/shopify-app-remix/docs/generated/generated_docs_data.json @@ -9650,7 +9650,7 @@ "filePath": "src/server/types.ts", "syntaxKind": "TypeAliasDeclaration", "name": "ShopifyApp", - "value": "Config['distribution'] extends AppDistribution.ShopifyAdmin\n ? AdminApp\n : Config['distribution'] extends AppDistribution.SingleMerchant\n ? SingleMerchantApp\n : Config['distribution'] extends AppDistribution.AppStore\n ? AppStoreApp\n : AppStoreApp", + "value": "Config['distribution'] extends AppDistribution.ShopifyAdmin\n ? AdminApp\n : Config['distribution'] extends AppDistribution.SingleMerchant\n ? SingleMerchantApp\n : Config['distribution'] extends AppDistribution.AppStore\n ? AppStoreApp\n : AppStoreApp", "description": "An object your app can use to interact with Shopify.\n\nBy default, the app's distribution is `AppStore`." }, "AdminApp": { @@ -14186,18 +14186,18 @@ "syntaxKind": "PropertySignature", "name": "admin", "value": "AdminApiContext", - "description": "Methods for interacting with the GraphQL / REST Admin APIs for the given store.\n\n *", + "description": "Methods for interacting with the GraphQL / REST Admin APIs for the given store.", "examples": [ { "title": "Performing a GET request to the REST API", "description": "Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint", "tabs": [ { - "code": "import { LoaderFunctionArgs, json } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport const loader = async ({ request }: LoaderFunctionArgs) => {\nconst { admin, session } = await unauthenticated.admin(request);\nconst response = await admin.rest.get({ path: \"/customers/count.json\" });\nconst customers = await response.json();\nreturn json({ customers });\n};", + "code": "import { LoaderFunctionArgs, json } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport const loader = async ({ request }: LoaderFunctionArgs) => {\n const { admin, session } = await unauthenticated.admin(request);\n\n const response = await admin.rest.get(\n {\n path: \"/customers/count.json\"\n }\n );\n const customers = await response.json();\n\n return json({ customers });\n};", "title": "/app/routes/**\\/*.ts" }, { - "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\nimport { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n\nconst shopify = shopifyApp({\nrestResources,\n// ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", + "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\nimport { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n\nconst shopify = shopifyApp({\n restResources,\n // ...etc\n});\n\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", "title": "/app/shopify.server.ts" } ] @@ -14207,11 +14207,11 @@ "description": "Use `admin.graphql` to make query / mutation requests.", "tabs": [ { - "code": "import { ActionFunctionArgs } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport async function action({ request }: ActionFunctionArgs) {\nconst { admin } = await unauthenticated.admin(request);\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 { variables: { input: { title: \"Product Name\" } } }\n);\n\nconst productData = await response.json();\nreturn json({ data: productData.data });\n}", - "title": "Example" + "code": "import { ActionFunctionArgs } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport async function action({ request }: ActionFunctionArgs) {\n const { admin } = await unauthenticated.admin(request);\n\n const response = await admin.graphql(\n `#graphql\n mutation populateProduct($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n }\n }\n }`,\n { variables: { input: { title: \"Product Name\" } } }\n );\n\n const productData = await response.json();\n return json({ data: productData.data });\n}", + "title": "/app/routes/**\\/*.ts" }, { - "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n\nconst shopify = shopifyApp({\nrestResources,\n// ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", + "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n\nconst shopify = shopifyApp({\n restResources,\n // ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", "title": "/app/shopify.server.ts" } ] @@ -14219,7 +14219,7 @@ ] } ], - "value": "export interface UnauthenticatedAdminContext<\n Resources extends ShopifyRestResources,\n> {\n /**\n * The session for the given shop.\n *\n * This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice.\n *\n * This will always be an offline session. You can use to get shop-specific data.\n *\n * @example\n * Using the offline session.\n * Get your app's shop-specific data using the returned offline `session` object.\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n * import { getMyAppData } from \"~/db/model.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const shop = getShopFromExternalRequest(request);\n * const { session } = await unauthenticated.admin(shop);\n * return json(await getMyAppData({shop: session.shop));\n * };\n * ```\n */\n session: Session;\n\n /**\n * Methods for interacting with the GraphQL / REST Admin APIs for the given store.\n *\n * * @example\n * Performing a GET request to the REST API.\n * Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint\n *\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const { admin, session } = await unauthenticated.admin(request);\n * const response = await admin.rest.get({ path: \"/customers/count.json\" });\n * const customers = await response.json();\n * return json({ customers });\n * };\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n * import { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n * @example\n * Querying the GraphQL API.\n * Use `admin.graphql` to make query / mutation requests.\n * ```ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const { admin } = await unauthenticated.admin(request);\n *\n * const response = await admin.graphql(\n * `#graphql\n * mutation populateProduct($input: ProductInput!) {\n * productCreate(input: $input) {\n * product {\n * id\n * }\n * }\n * }`,\n * { variables: { input: { title: \"Product Name\" } } }\n * );\n *\n * const productData = await response.json();\n * return json({ data: productData.data });\n * }\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n */\n admin: AdminApiContext;\n}" + "value": "export interface UnauthenticatedAdminContext<\n Resources extends ShopifyRestResources,\n> {\n /**\n * The session for the given shop.\n *\n * This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice.\n *\n * This will always be an offline session. You can use to get shop-specific data.\n *\n * @example\n * Using the offline session.\n * Get your app's shop-specific data using the returned offline `session` object.\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n * import { getMyAppData } from \"~/db/model.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const shop = getShopFromExternalRequest(request);\n * const { session } = await unauthenticated.admin(shop);\n * return json(await getMyAppData({shop: session.shop));\n * };\n * ```\n */\n session: Session;\n\n /**\n * Methods for interacting with the GraphQL / REST Admin APIs for the given store.\n *\n * @example\n * Performing a GET request to the REST API.\n * Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint\n *\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const { admin, session } = await unauthenticated.admin(request);\n *\n * const response = await admin.rest.get(\n * {\n * path: \"/customers/count.json\"\n * }\n * );\n * const customers = await response.json();\n *\n * return json({ customers });\n * };\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n * import { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n *\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n * @example\n * Querying the GraphQL API.\n * Use `admin.graphql` to make query / mutation requests.\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const { admin } = await unauthenticated.admin(request);\n *\n * const response = await admin.graphql(\n * `#graphql\n * mutation populateProduct($input: ProductInput!) {\n * productCreate(input: $input) {\n * product {\n * id\n * }\n * }\n * }`,\n * { variables: { input: { title: \"Product Name\" } } }\n * );\n *\n * const productData = await response.json();\n * return json({ data: productData.data });\n * }\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n */\n admin: AdminApiContext;\n}" }, "GetUnauthenticatedStorefrontContext": { "filePath": "src/server/unauthenticated/storefront/types.ts", @@ -14759,18 +14759,18 @@ "syntaxKind": "PropertySignature", "name": "admin", "value": "AdminApiContext", - "description": "Methods for interacting with the GraphQL / REST Admin APIs for the given store.\n\n *", + "description": "Methods for interacting with the GraphQL / REST Admin APIs for the given store.", "examples": [ { "title": "Performing a GET request to the REST API", "description": "Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint", "tabs": [ { - "code": "import { LoaderFunctionArgs, json } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport const loader = async ({ request }: LoaderFunctionArgs) => {\nconst { admin, session } = await unauthenticated.admin(request);\nconst response = await admin.rest.get({ path: \"/customers/count.json\" });\nconst customers = await response.json();\nreturn json({ customers });\n};", + "code": "import { LoaderFunctionArgs, json } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport const loader = async ({ request }: LoaderFunctionArgs) => {\n const { admin, session } = await unauthenticated.admin(request);\n\n const response = await admin.rest.get(\n {\n path: \"/customers/count.json\"\n }\n );\n const customers = await response.json();\n\n return json({ customers });\n};", "title": "/app/routes/**\\/*.ts" }, { - "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\nimport { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n\nconst shopify = shopifyApp({\nrestResources,\n// ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", + "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\nimport { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n\nconst shopify = shopifyApp({\n restResources,\n // ...etc\n});\n\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", "title": "/app/shopify.server.ts" } ] @@ -14780,11 +14780,11 @@ "description": "Use `admin.graphql` to make query / mutation requests.", "tabs": [ { - "code": "import { ActionFunctionArgs } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport async function action({ request }: ActionFunctionArgs) {\nconst { admin } = await unauthenticated.admin(request);\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 { variables: { input: { title: \"Product Name\" } } }\n);\n\nconst productData = await response.json();\nreturn json({ data: productData.data });\n}", - "title": "Example" + "code": "import { ActionFunctionArgs } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport async function action({ request }: ActionFunctionArgs) {\n const { admin } = await unauthenticated.admin(request);\n\n const response = await admin.graphql(\n `#graphql\n mutation populateProduct($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n }\n }\n }`,\n { variables: { input: { title: \"Product Name\" } } }\n );\n\n const productData = await response.json();\n return json({ data: productData.data });\n}", + "title": "/app/routes/**\\/*.ts" }, { - "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n\nconst shopify = shopifyApp({\nrestResources,\n// ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", + "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n\nconst shopify = shopifyApp({\n restResources,\n // ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", "title": "/app/shopify.server.ts" } ] @@ -14792,7 +14792,7 @@ ] } ], - "value": "export interface UnauthenticatedAdminContext<\n Resources extends ShopifyRestResources,\n> {\n /**\n * The session for the given shop.\n *\n * This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice.\n *\n * This will always be an offline session. You can use to get shop-specific data.\n *\n * @example\n * Using the offline session.\n * Get your app's shop-specific data using the returned offline `session` object.\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n * import { getMyAppData } from \"~/db/model.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const shop = getShopFromExternalRequest(request);\n * const { session } = await unauthenticated.admin(shop);\n * return json(await getMyAppData({shop: session.shop));\n * };\n * ```\n */\n session: Session;\n\n /**\n * Methods for interacting with the GraphQL / REST Admin APIs for the given store.\n *\n * * @example\n * Performing a GET request to the REST API.\n * Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint\n *\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const { admin, session } = await unauthenticated.admin(request);\n * const response = await admin.rest.get({ path: \"/customers/count.json\" });\n * const customers = await response.json();\n * return json({ customers });\n * };\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n * import { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n * @example\n * Querying the GraphQL API.\n * Use `admin.graphql` to make query / mutation requests.\n * ```ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const { admin } = await unauthenticated.admin(request);\n *\n * const response = await admin.graphql(\n * `#graphql\n * mutation populateProduct($input: ProductInput!) {\n * productCreate(input: $input) {\n * product {\n * id\n * }\n * }\n * }`,\n * { variables: { input: { title: \"Product Name\" } } }\n * );\n *\n * const productData = await response.json();\n * return json({ data: productData.data });\n * }\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n */\n admin: AdminApiContext;\n}" + "value": "export interface UnauthenticatedAdminContext<\n Resources extends ShopifyRestResources,\n> {\n /**\n * The session for the given shop.\n *\n * This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice.\n *\n * This will always be an offline session. You can use to get shop-specific data.\n *\n * @example\n * Using the offline session.\n * Get your app's shop-specific data using the returned offline `session` object.\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n * import { getMyAppData } from \"~/db/model.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const shop = getShopFromExternalRequest(request);\n * const { session } = await unauthenticated.admin(shop);\n * return json(await getMyAppData({shop: session.shop));\n * };\n * ```\n */\n session: Session;\n\n /**\n * Methods for interacting with the GraphQL / REST Admin APIs for the given store.\n *\n * @example\n * Performing a GET request to the REST API.\n * Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint\n *\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export const loader = async ({ request }: LoaderFunctionArgs) => {\n * const { admin, session } = await unauthenticated.admin(request);\n *\n * const response = await admin.rest.get(\n * {\n * path: \"/customers/count.json\"\n * }\n * );\n * const customers = await response.json();\n *\n * return json({ customers });\n * };\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n * import { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n *\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n * @example\n * Querying the GraphQL API.\n * Use `admin.graphql` to make query / mutation requests.\n * ```ts\n * // /app/routes/**\\/*.ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { unauthenticated } from \"../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const { admin } = await unauthenticated.admin(request);\n *\n * const response = await admin.graphql(\n * `#graphql\n * mutation populateProduct($input: ProductInput!) {\n * productCreate(input: $input) {\n * product {\n * id\n * }\n * }\n * }`,\n * { variables: { input: { title: \"Product Name\" } } }\n * );\n *\n * const productData = await response.json();\n * return json({ data: productData.data });\n * }\n * ```\n *\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * restResources,\n * // ...etc\n * });\n * export default shopify;\n * export const unauthenticated = shopify.unauthenticated;\n * ```\n */\n admin: AdminApiContext;\n}" }, "Session": { "filePath": "../../node_modules/@shopify/shopify-api/lib/session/session.d.ts", @@ -15412,12 +15412,12 @@ "tabs": [ { "title": "/app/routes/**\\/*.ts", - "code": "import { LoaderFunctionArgs, json } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport const loader = async ({ request }: LoaderFunctionArgs) => {\nconst { admin, session } = await unauthenticated.admin(request);\nconst response = await admin.rest.get({ path: \"/customers/count.json\" });\nconst customers = await response.json();\nreturn json({ customers });\n};", + "code": "import { LoaderFunctionArgs, json } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport const loader = async ({ request }: LoaderFunctionArgs) => {\n const { admin, session } = await unauthenticated.admin(request);\n\n const response = await admin.rest.get(\n {\n path: \"/customers/count.json\"\n }\n );\n const customers = await response.json();\n\n return json({ customers });\n};", "language": "typescript" }, { "title": "/app/shopify.server.ts", - "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\nimport { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n\nconst shopify = shopifyApp({\nrestResources,\n// ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", + "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\nimport { restResources } from \"@shopify/shopify-api/rest/admin/2023-04\";\n\nconst shopify = shopifyApp({\n restResources,\n // ...etc\n});\n\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", "language": "typescript" } ] @@ -15429,13 +15429,13 @@ "title": "Querying the GraphQL API", "tabs": [ { - "title": "Example", - "code": "import { ActionFunctionArgs } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport async function action({ request }: ActionFunctionArgs) {\nconst { admin } = await unauthenticated.admin(request);\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 { variables: { input: { title: \"Product Name\" } } }\n);\n\nconst productData = await response.json();\nreturn json({ data: productData.data });\n}", + "title": "/app/routes/**\\/*.ts", + "code": "import { ActionFunctionArgs } from \"@remix-run/node\";\nimport { unauthenticated } from \"../shopify.server\";\n\nexport async function action({ request }: ActionFunctionArgs) {\n const { admin } = await unauthenticated.admin(request);\n\n const response = await admin.graphql(\n `#graphql\n mutation populateProduct($input: ProductInput!) {\n productCreate(input: $input) {\n product {\n id\n }\n }\n }`,\n { variables: { input: { title: \"Product Name\" } } }\n );\n\n const productData = await response.json();\n return json({ data: productData.data });\n}", "language": "typescript" }, { "title": "/app/shopify.server.ts", - "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n\nconst shopify = shopifyApp({\nrestResources,\n// ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", + "code": "import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n\nconst shopify = shopifyApp({\n restResources,\n // ...etc\n});\nexport default shopify;\nexport const unauthenticated = shopify.unauthenticated;", "language": "typescript" } ] diff --git a/packages/shopify-app-remix/src/server/types.ts b/packages/shopify-app-remix/src/server/types.ts index 40572e4e1f..54a1db1ed5 100644 --- a/packages/shopify-app-remix/src/server/types.ts +++ b/packages/shopify-app-remix/src/server/types.ts @@ -464,7 +464,7 @@ export type ShopifyApp = Config['distribution'] extends AppDistribution.ShopifyAdmin ? AdminApp : Config['distribution'] extends AppDistribution.SingleMerchant - ? SingleMerchantApp - : Config['distribution'] extends AppDistribution.AppStore - ? AppStoreApp - : AppStoreApp; + ? SingleMerchantApp + : Config['distribution'] extends AppDistribution.AppStore + ? AppStoreApp + : AppStoreApp; diff --git a/packages/shopify-app-remix/src/server/unauthenticated/admin/types.ts b/packages/shopify-app-remix/src/server/unauthenticated/admin/types.ts index f7b5b1fbc8..6ae7311883 100644 --- a/packages/shopify-app-remix/src/server/unauthenticated/admin/types.ts +++ b/packages/shopify-app-remix/src/server/unauthenticated/admin/types.ts @@ -33,7 +33,7 @@ export interface UnauthenticatedAdminContext< /** * Methods for interacting with the GraphQL / REST Admin APIs for the given store. * - * * @example + * @example * Performing a GET request to the REST API. * Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint * @@ -43,10 +43,16 @@ export interface UnauthenticatedAdminContext< * import { unauthenticated } from "../shopify.server"; * * export const loader = async ({ request }: LoaderFunctionArgs) => { - * const { admin, session } = await unauthenticated.admin(request); - * const response = await admin.rest.get({ path: "/customers/count.json" }); - * const customers = await response.json(); - * return json({ customers }); + * const { admin, session } = await unauthenticated.admin(request); + * + * const response = await admin.rest.get( + * { + * path: "/customers/count.json" + * } + * ); + * const customers = await response.json(); + * + * return json({ customers }); * }; * ``` * @@ -56,9 +62,10 @@ export interface UnauthenticatedAdminContext< * import { restResources } from "@shopify/shopify-api/rest/admin/2023-04"; * * const shopify = shopifyApp({ - * restResources, - * // ...etc + * restResources, + * // ...etc * }); + * * export default shopify; * export const unauthenticated = shopify.unauthenticated; * ``` @@ -66,26 +73,27 @@ export interface UnauthenticatedAdminContext< * Querying the GraphQL API. * Use `admin.graphql` to make query / mutation requests. * ```ts + * // /app/routes/**\/*.ts * import { ActionFunctionArgs } from "@remix-run/node"; * import { unauthenticated } from "../shopify.server"; * * export async function action({ request }: ActionFunctionArgs) { - * const { admin } = await unauthenticated.admin(request); - * - * const response = await admin.graphql( - * `#graphql - * mutation populateProduct($input: ProductInput!) { - * productCreate(input: $input) { - * product { - * id - * } - * } + * const { admin } = await unauthenticated.admin(request); + * + * 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(); - * return json({ data: productData.data }); + * const productData = await response.json(); + * return json({ data: productData.data }); * } * ``` * @@ -94,8 +102,8 @@ export interface UnauthenticatedAdminContext< * import { shopifyApp } from "@shopify/shopify-app-remix/server"; * * const shopify = shopifyApp({ - * restResources, - * // ...etc + * restResources, + * // ...etc * }); * export default shopify; * export const unauthenticated = shopify.unauthenticated;