Tento Upsert

Tento represents Shopify Upsert Metaobject mutation

The object that you pass to update should have keys that match field names in your Metaobject Definition schema. If no matching metaobject is found, a new metaobject is created with the provided input values.

index.ts
schema.ts
import { tento } from "@drizzle-team/tento";
import * as schema from "./schema";

const client = tento({ schema });

const result = await client.metaobjects.designer.upsert("designer-handle", {
  fields: {
    name: "Alex",
  },
});
// return type
const result: {
  _id: string;
  _handle: string;
  _displayName: string;
  _updatedAt: Date;
  name: string;
  description: string | null;
  website: string | null;
}

As for update you can provide capabilities for metaobject, to do so you can provide publishable capability input:

const result = await client.metaobjects.designer.upsert("designer-handle", {
  fields: {
    name: "Alex",
  },
  capabilities: {
    publishable: {
      status: "ACTIVE", // ACTIVE | DRAFT
    },
  },
});
// return type
const result: {
  _id: string;
  _handle: string;
  _displayName: string;
  _updatedAt: Date;
  name: string;
  description: string | null;
  website: string | null;
}