How to access Prisma database from POS UI Extension

Hi all, I’m new to Shopify app development, but have experience with TypeScript. I’m trying to create a POS extension app that’s linked to an admin app. I have created the admin app which successfully stores data (productIDs) in a primsa database:

model Product {
  id  Int @id @default(autoincrement())
  globalId String
  addedDate DateTime @default(now())
}

export const addProducts = async (productIds: Prisma.ProductCreateManyInput[]): Promise<void> => {
  await prisma.product.createMany({
    data: productIds,
  })
}

I then need to access the data from my POS app. I’ve tried calling the following from my modal:

export const getProducts = async () => {
  const products = await prisma.product.findMany();
  return products;
}

However I’m getting the following error - Unhandled Promise Rejection: ReferenceError: Can't find variable: global This is my prisma file:

import { PrismaClient } from "@prisma/client";

declare global {
  var prisma: PrismaClient;
}

if (process.env.NODE_ENV !== "production") {
  if (!global.prisma) {
    global.prisma = new PrismaClient();
  }
}

const prisma: PrismaClient = global.prisma || new PrismaClient();

export default prisma;

Am I getting this completely wrong? Is it even possible to access the primsa database from the POS app, or should I be looking at another method? I’ve noticed mentioned of proxies/session tokens in the docs, but really there’s no examples of how this should work. I’d really appreciate a nudge in the right direction! Thanks.

As with all Shopify UI Extensions, the browser/window/global is patched so that all methods are not available.
You can’t rely on anything outside of fetch being available so should move this work to your own API :slight_smile:

There is this old list that is available but not sure if there is an up to date one ui-extensions/documentation/runtime-environment.md at 0e7aab20eb46ac7b6b57e8ec56ebc06ee931f81c · Shopify/ui-extensions · GitHub