The `authenticate.public.appProxy` function validates app proxy requests made by Shopify, and returns a context to enable querying Shopify APIs.
Authenticates requests coming from Shopify app proxies.
request: Request
export type AuthenticateAppProxy = ( request: Request, ) => Promise<AppProxyContext | AppProxyContextWithSession>;
No session is available for the shop that made this request. This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice.
No session is available for the shop that made this request. Therefore no methods for interacting with the GraphQL / REST Admin APIs are available.
No session is available for the shop that made this request. Therefore no method for interacting with the Storefront API is available.
A utility for creating a Liquid Response.
body: string
initAndOptions: number | (ResponseInit & Options)
export type LiquidResponseFunction = ( body: string, initAndOptions?: number | (ResponseInit & Options), ) => Response;
The session for the shop that made the request. This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice. Use this to get shop or user-specific data.
Methods for interacting with the GraphQL / REST Admin APIs for the store that made the request.
Method for interacting with the Shopify Storefront Graphql API for the store that made the request.
A utility for creating a Liquid Response.
Methods for interacting with the Shopify Admin REST API There are methods for interacting with individual REST resources. You can also make `GET`, `POST`, `PUT` and `DELETE` requests should the REST resources not meet your needs.
Methods for interacting with the Shopify Admin GraphQL API
RemixRestClient & {resources: Resources}
Method for interacting with the Shopify Storefront GraphQL API If you're getting incorrect type hints in the Shopify template, follow [these instructions](https://github.com/Shopify/shopify-app-template-remix/tree/main#incorrect-graphql-hints).
The `authenticate.public.appProxy` function validates app proxy requests made by Shopify, and returns a context to enable querying Shopify APIs.
import { json } from "@remix-run/node";
import { authenticate } from "../shopify.server";
import { getMyAppModelData } from "~/db/model.server";
export const loader = async ({ request }) => {
const { session } = await authenticate.public.appProxy(request);
return json(await getMyAppModelData({shop: session.shop));
};
import { json } from "@remix-run/node";
import { authenticate } from "../shopify.server";
export async function action({ request }: ActionArgs) {
const { admin } = await authenticate.public.appProxy(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 });
}
import { json } from "@remix-run/node";
import { authenticate } from "../shopify.server";
export async function action({ request }: ActionArgs) {
const { admin } = await authenticate.public.appProxy(request);
const response = await storefront.graphql(`{blogs(first: 10) { edges { node { id } } } }`);
return json(await response.json());
}
import {authenticate} from "~/shopify.server"
export async function loader({ request }) {
const {liquid} = authenticate.public.appProxy(request);
return liquid("Hello {{shop.name}}")
}