Skip to content

Commit

Permalink
Merge pull request #675 from Shopify/fix_remix_docs
Browse files Browse the repository at this point in the history
Fix remix docs
  • Loading branch information
paulomarg authored Feb 28, 2024
2 parents fff67dc + b4d506d commit ebce731
Show file tree
Hide file tree
Showing 12 changed files with 3,979 additions and 3,100 deletions.
2 changes: 2 additions & 0 deletions .changeset/popular-goats-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
6,778 changes: 3,746 additions & 3,032 deletions packages/shopify-app-remix/docs/generated/generated_docs_data.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@
"description": "Returns the same `admin` context (`AdminApiContext`) from `authenticate.webhook` that is returned from `authenticate.admin`.\n\nSee [authenticate.webhook](/docs/api/shopify-app-remix/authenticate/webhook#example-admin) for more details.",
"isOptional": true
},
{
"name": "v3_lineItemBilling",
"value": "",
"description": "Allows you to pass billing plans with up to two line items when creating a new app subscription.\n\n This allows you to create app subscriptions with both recurring and usage based components.",
"isOptional": true
},
{
"name": "unstable_newEmbeddedAuthStrategy",
"value": "",
Expand Down Expand Up @@ -518,7 +524,7 @@
"tabs": [
{
"title": "/app/routes/webhooks.tsx",
"code": "import {ActionFunction} from '@remix-run/node';\n\nimport db from '../db.server';\n\nimport {authenticate} from '~/shopify.server';\n\nexport const action: ActionFunction = async ({request}) => {\n const {topic, shop, session} = await authenticate.webhook(request);\n\n switch (topic) {\n case 'APP_UNINSTALLED':\n if (session) {\n await db.session.deleteMany({where: {shop}});\n }\n break;\n case 'CUSTOMERS_DATA_REQUEST':\n case 'CUSTOMERS_REDACT':\n case 'SHOP_REDACT':\n default:\n throw new Response('Unhandled webhook topic', {status: 404});\n }\n\n throw new Response();\n};\n",
"code": "import {ActionFunctionArgs} from '@remix-run/node';\n\nimport db from '../db.server';\n\nimport {authenticate} from '~/shopify.server';\n\nexport const action = async ({request}: ActionFunctionArgs) => {\n const {topic, shop, session} = await authenticate.webhook(request);\n\n switch (topic) {\n case 'APP_UNINSTALLED':\n if (session) {\n await db.session.deleteMany({where: {shop}});\n }\n break;\n case 'CUSTOMERS_DATA_REQUEST':\n case 'CUSTOMERS_REDACT':\n case 'SHOP_REDACT':\n default:\n throw new Response('Unhandled webhook topic', {status: 404});\n }\n\n throw new Response();\n};\n",
"language": "tsx"
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {ActionFunction} from '@remix-run/node';
import {ActionFunctionArgs} from '@remix-run/node';

import db from '../db.server';

import {authenticate} from '~/shopify.server';

export const action: ActionFunction = async ({request}) => {
export const action = async ({request}: ActionFunctionArgs) => {
const {topic, shop, session} = await authenticate.webhook(request);

switch (topic) {
Expand Down
54 changes: 27 additions & 27 deletions packages/shopify-app-remix/src/server/authenticate/admin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ interface AdminContextInternal<
* <caption>Using offline sessions.</caption>
* <description>Get your app's shop-specific data using an offline session.</description>
* ```ts
* // shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
*
* const shopify = shopifyApp({
* // ...etc
* });
* export default shopify;
* export const authenticate = shopify.authenticate;
* ```
* ```ts
* // /app/routes/**\/*.ts
* import { LoaderFunctionArgs, json } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
Expand All @@ -42,21 +32,20 @@ interface AdminContextInternal<
* return json(await getMyAppData({shop: session.shop));
* };
* ```
*
* @example
* <caption>Using online sessions.</caption>
* <description>Get your app's user-specific data using an online session.</description>
* ```ts
* // shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
*
* const shopify = shopifyApp({
* // ...etc
* useOnlineTokens: true,
* });
* export default shopify;
* export const authenticate = shopify.authenticate;
* ```
*
* @example
* <caption>Using online sessions.</caption>
* <description>Get your app's user-specific data using an online session.</description>
* ```ts
* // /app/routes/**\/*.ts
* import { LoaderFunctionArgs, json } from "@remix-run/node";
Expand All @@ -68,6 +57,17 @@ interface AdminContextInternal<
* return json(await getMyAppData({user: session.onlineAccessInfo!.id}));
* };
* ```
* ```ts
* // shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
*
* const shopify = shopifyApp({
* // ...etc
* useOnlineTokens: true,
* });
* export default shopify;
* export const authenticate = shopify.authenticate;
* ```
*/
session: Session;

Expand Down Expand Up @@ -119,29 +119,29 @@ export interface EmbeddedAdminContext<
* <caption>Using the decoded session token.</caption>
* <description>Get user-specific data using the `sessionToken` object.</description>
* ```ts
* // shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
*
* const shopify = shopifyApp({
* // ...etc
* useOnlineTokens: true,
* });
* export default shopify;
* export const authenticate = shopify.authenticate;
* ```
* ```ts
* // /app/routes/**\/*.ts
* import { LoaderFunctionArgs, json } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
* import { getMyAppData } from "~/db/model.server";
*
* export const loader = async ({ request }: LoaderFunctionArgs) => {
* const { sessionToken } = await authenticate.public.checkout(
* const { sessionToken } = await authenticate.admin(
* request
* );
* return json(await getMyAppData({user: sessionToken.sub}));
* };
* ```
* ```ts
* // shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
*
* const shopify = shopifyApp({
* // ...etc
* useOnlineTokens: true,
* });
* export default shopify;
* export const authenticate = shopify.authenticate;
* ```
*/
sessionToken: JwtPayload;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export interface FlowContext<
* <description>Use the session associated with this request to use REST resources.</description>
* ```ts
* // /app/routes/flow.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { session, admin } = await authenticate.flow(request);
*
* const products = await admin?.rest.resources.Product.all({ session });
Expand All @@ -38,10 +38,10 @@ export interface FlowContext<
* <description>Get the request's POST payload.</description>
* ```ts
* // /app/routes/flow.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { payload } = await authenticate.flow(request);
* return new Response();
* };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const data: ReferenceEntityTemplateSchema = {
subtitle: 'Interact with the Storefront API.',
url: '/docs/api/shopify-app-remix/apis/storefront-api',
},
{
name: 'Liquid reference',
subtitle: "Use the shop's theme to render a template.",
url: '/docs/api/liquid',
type: 'liquid',
},
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Context {
*
* @example
* <caption>Rendering liquid content.</caption>
* <description>Use the `liquid` helper to render a `Response` with Liquid content using the shop's theme.</description>
* <description>Use the `liquid` helper to render a `Response` with Liquid content using the shop's theme. See the [Liquid reference](https://shopify.dev/docs/api/liquid) for all the features it enables.</description>
* ```ts
* // app/routes/**\/.ts
* import {authenticate} from "~/shopify.server"
Expand Down Expand Up @@ -98,10 +98,13 @@ export interface AppProxyContextWithSession<
*
* export const loader = async ({ request }) => {
* // Get the session for the shop that initiated the request to the app proxy.
* const { session } = await authenticate.public.appProxy(request);
* const { session } =
* await authenticate.public.appProxy(request);
*
* // Use the session data to make to queries to your database or additional requests.
* return json(await getMyAppModelData({shop: session.shop));
* return json(
* await getMyAppModelData({shop: session.shop})
* );
* };
* ```
*/
Expand Down Expand Up @@ -130,7 +133,11 @@ export interface AppProxyContextWithSession<
* }
* }
* }`,
* { variables: { input: { title: "Product Name" } } }
* {
* variables: {
* input: { title: "Product Name" }
* }
* }
* );
*
* const productData = await response.json();
Expand All @@ -154,7 +161,18 @@ export interface AppProxyContextWithSession<
* export async function action({ request }: ActionFunctionArgs) {
* const { storefront } = await authenticate.public.appProxy(request);
*
* const response = await storefront.graphql(`{blogs(first: 10) { edges { node { id } } } }`);
* const response = await storefront.graphql(
* `#graphql
* query blogIds {
* blogs(first: 10) {
* edges {
* node {
* id
* }
* }
* }
* }`
* );
*
* return json(await response.json());
* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ interface Context<Topics = string | number | symbol> {
* <description>Get the API version used for webhook request.</description>
* ```ts
* // /app/routes/webhooks.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { apiVersion } = await authenticate.webhook(request);
* return new Response();
* };
Expand All @@ -38,10 +38,10 @@ interface Context<Topics = string | number | symbol> {
* <description>Get the shop that triggered a webhook.</description>
* ```ts
* // /app/routes/webhooks.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { shop } = await authenticate.webhook(request);
* return new Response();
* };
Expand All @@ -56,10 +56,10 @@ interface Context<Topics = string | number | symbol> {
* <description>Get the event topic for the webhook.</description>
* ```ts
* // /app/routes/webhooks.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { topic } = await authenticate.webhook(request);
*
* switch (topic) {
Expand All @@ -81,10 +81,10 @@ interface Context<Topics = string | number | symbol> {
* <description>Get the webhook ID.</description>
* ```ts
* // /app/routes/webhooks.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { webhookId } = await authenticate.webhook(request);
* return new Response();
* };
Expand All @@ -99,10 +99,10 @@ interface Context<Topics = string | number | symbol> {
* <description>Get the request's POST payload.</description>
* ```ts
* // /app/routes/webhooks.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { payload } = await authenticate.webhook(request);
* return new Response();
* };
Expand All @@ -117,10 +117,10 @@ interface Context<Topics = string | number | symbol> {
* <description>Get the webhook sub-topic.</description>
* ```ts
* // /app/routes/webhooks.tsx
* import { ActionFunction } from "@remix-run/node";
* import { ActionFunctionArgs } from "@remix-run/node";
* import { authenticate } from "../shopify.server";
*
* export const action: ActionFunction = async ({ request }) => {
* export const action = async ({ request }: ActionFunctionArgs) => {
* const { subTopic } = await authenticate.webhook(request);
* return new Response();
* };
Expand Down
Loading

0 comments on commit ebce731

Please sign in to comment.