Storefront APIobject
object
Contains objects used to interact with the Storefront API.
This object is returned as part of different contexts, such as , and
unauthenticated.storefront
.
Anchor to storefrontstorefront
Provides utilities that apps can use to make requests to the Storefront API.
Anchor to graphql
graphql
<StorefrontOperations>
required
Method for interacting with the Shopify Storefront GraphQL API
If you're getting incorrect type hints in the Shopify template, follow these instructions.
Was this section helpful?
Anchor to examplesExamples
Anchor to example-graphqlgraphql
Anchor to example-querying-the-graphql-apiQuerying the GraphQL API
Use storefront.graphql
to make query / mutation requests.
Anchor to example-handling-graphql-errorsHandling GraphQL errors
Catch errors to see error messages from the API.
Was this section helpful?
Querying the GraphQL API
app/routes/**\/.ts
import { json } from "@remix-run/node";
import { authenticate } from "../shopify.server";
export async function action({ request }: ActionFunctionArgs) {
const { storefront } = await authenticate.public.appProxy(request);
const response = await storefront.graphql(`{blogs(first: 10) { edges { node { id } } } }`);
return json(await response.json());
}