Admin APIobject
object
Contains objects used to interact with the Admin API.
This object is returned as part of different contexts, such as admin
, unauthenticated.admin
, and webhook
.
Anchor to adminadmin
Provides utilities that apps can use to make requests to the Admin API.
FeatureEnabled<ConfigArg['future'], 'removeRest'> extends true
? AdminApiContextWithoutRest
: AdminApiContextWithRest<Resources>
Anchor to AdminApiContextWithRest
AdminApiContextWithRest
Anchor to graphql
graphql
<AdminOperations>
required
Methods for interacting with the Shopify Admin GraphQL API
Anchor to rest
rest
<Resources>
required
Methods for interacting with the Shopify Admin REST API
Deprecated
In a future major release REST will be removed from this package. Please see all-in on graphql.
There are methods for interacting with individual REST resources. You can also make ,
,
and
requests should the REST resources not meet your needs.
Anchor to AdminApiContextWithoutRest
AdminApiContextWithoutRest
Anchor to graphql
graphql
<AdminOperations>
required
Methods for interacting with the Shopify Admin GraphQL API
Anchor to FeatureEnabled
FeatureEnabled
Future extends
? Future[Flag] extends true
? true
: false
: false
Was this section helpful?
Anchor to examplesExamples
Anchor to example-graphqlgraphql
Anchor to example-querying-the-graphql-apiQuerying the GraphQL API
Use admin.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
import { ActionFunctionArgs } from "@remix-run/node";
import { authenticate } from "../shopify.server";
export const action = async ({ request }: ActionFunctionArgs) => {
const { admin } = await authenticate.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({
productId: productData.data?.productCreate?.product?.id,
});
}