Skip to content

Commit

Permalink
Merge pull request #629 from Shopify/liz/update-docs
Browse files Browse the repository at this point in the history
Fix various docs issues
  • Loading branch information
lizkenyon authored Feb 5, 2024
2 parents 5867281 + 52631cc commit f0acc9b
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 72 deletions.
2 changes: 2 additions & 0 deletions .changeset/big-humans-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
1 change: 1 addition & 0 deletions packages/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@shopify/prettier-config"
195 changes: 126 additions & 69 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 @@ -104,7 +104,7 @@ export interface BillingContext<Config extends AppConfigArg> {
* ```
*
* @example
* <caption>Using a plan selection page.</caption>
* <caption>Redirect to a plan selection page.</caption>
* <description> When the app has multiple plans, create a page in your App that allows the merchant to select a plan. If a merchant does not have the required plan you can redirect them to page in your app to select one.</description>
* ```ts
* // /app/routes/**\/*.ts
Expand Down
12 changes: 12 additions & 0 deletions packages/shopify-app-remix/src/server/clients/admin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ export interface AdminApiContext<
* return json({ data: productData.data });
* }
* ```
*
* ```ts
* // /app/shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
*
* const shopify = shopifyApp({
* restResources,
* // ...etc
* });
* export default shopify;
* export const unauthenticated = shopify.unauthenticated;
* ```
*/
graphql: GraphQLClient<AdminOperations>;
}
2 changes: 1 addition & 1 deletion packages/shopify-app-remix/src/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export interface ShopifyAppBase<Config extends AppConfigArg> {
* import prisma from "~/db.server";
*
* const shopify = shopifyApp({
* sesssionStorage: new PrismaSessionStorage(prisma),
* sessionStorage: new PrismaSessionStorage(prisma),
* // ...etc
* })
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,82 @@ export interface UnauthenticatedAdminContext<

/**
* Methods for interacting with the GraphQL / REST Admin APIs for the given store.
*
* @example
* <caption>Performing a GET request to the REST API.</caption>
* <description>Use `admin.rest.get` to make custom requests to make a request to to the `customer/count` endpoint</description>
*
* ```ts
* // /app/routes/**\/*.ts
* import { LoaderFunctionArgs, json } from "@remix-run/node";
* 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 });
* };
* ```
*
* ```ts
* // /app/shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
* import { restResources } from "@shopify/shopify-api/rest/admin/2023-04";
*
* const shopify = shopifyApp({
* restResources,
* // ...etc
* });
*
* export default shopify;
* export const unauthenticated = shopify.unauthenticated;
* ```
* @example
* <caption>Querying the GraphQL API.</caption>
* <description>Use `admin.graphql` to make query / mutation requests.</description>
* ```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
* }
* }
* }`,
* { variables: { input: { title: "Product Name" } } }
* );
*
* const productData = await response.json();
* return json({ data: productData.data });
* }
* ```
*
* ```ts
* // /app/shopify.server.ts
* import { shopifyApp } from "@shopify/shopify-app-remix/server";
*
* const shopify = shopifyApp({
* restResources,
* // ...etc
* });
* export default shopify;
* export const unauthenticated = shopify.unauthenticated;
* ```
*/
admin: AdminApiContext<Resources>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const data: ReferenceEntityTemplateSchema = {
type: 'GetUnauthenticatedAdminContext',
},
],
jsDocTypeExamples: ['UnauthenticatedAdminContext', 'AdminApiContext'],
jsDocTypeExamples: ['UnauthenticatedAdminContext'],
related: [
{
name: 'API context',
Expand Down

0 comments on commit f0acc9b

Please sign in to comment.