Customer account extension

I have a custom model, that I want cusomters to only be able to view ones related to their id (record belongs to a s shopify customer), but the shop merchant/admin should be able to view all records beloning to their shop (every record also belongs to a shopifyShop). What should the tenacy look like? https://docs.gadget.dev/guides/plugins/shopify/customer-account-ui-extensions#adding-a-tenancy-filter
12 Replies
Jay
JayOP7mo ago
I think I need to create a filter for the role shopify-storefront-customers
Chocci_Milk
Chocci_Milk7mo ago
Yes I would recommend looking st the base tenacy filters that are written for shopify models then try to copy that one
Jay
JayOP7mo ago
Perfect!
Jay
JayOP7mo ago
On the dev env it worked fine, and on the live it didn't
No description
Jay
JayOP7mo ago
{
"errors": [
{
"message": "GGT_INVALID_SHOPIFY_SESSION_TOKEN: Invalid Shopify Session Token passed in Authorization header, token could not be decoded",
"extensions": {
"fromSandbox": false
}
}
],
"data": null,
"extensions": {
"logs": "https://ggt.link/logs/381140/f2a937e04b7780d4a3cef234d28cea74",
"traceId": "f2a937e04b7780d4a3cef234d28cea74"
}
}
{
"errors": [
{
"message": "GGT_INVALID_SHOPIFY_SESSION_TOKEN: Invalid Shopify Session Token passed in Authorization header, token could not be decoded",
"extensions": {
"fromSandbox": false
}
}
],
"data": null,
"extensions": {
"logs": "https://ggt.link/logs/381140/f2a937e04b7780d4a3cef234d28cea74",
"traceId": "f2a937e04b7780d4a3cef234d28cea74"
}
}
Chocci_Milk
Chocci_Milk7mo ago
Are you pointing to the correct env in the client instantiation?
Jay
JayOP7mo ago
aha!
import { Client } from "@gadget-client/bulk-orders";
import { useFindMany } from "@gadgetinc/react";
import { Provider, useGadget } from "@gadgetinc/shopify-extensions/react";
import type { AnyClient } from "@gadgetinc/api-client-core";
import { Client } from "@gadget-client/bulk-orders";
import { useFindMany } from "@gadgetinc/react";
import { Provider, useGadget } from "@gadgetinc/shopify-extensions/react";
import type { AnyClient } from "@gadgetinc/api-client-core";
Chocci_Milk
Chocci_Milk7mo ago
Thats an import, not a new instance of the Client
Jay
JayOP7mo ago
thisis a customer account extension how do I choose the env this is how im initiaitn the client
import { Client } from "@gadget-client/bulk-orders";
import { useFindMany } from "@gadgetinc/react";
import { Provider, useGadget } from "@gadgetinc/shopify-extensions/react";
import type { AnyClient } from "@gadgetinc/api-client-core";

// initialize a new Client for your Gadget API
const client = new Client();
import { Client } from "@gadget-client/bulk-orders";
import { useFindMany } from "@gadgetinc/react";
import { Provider, useGadget } from "@gadgetinc/shopify-extensions/react";
import type { AnyClient } from "@gadgetinc/api-client-core";

// initialize a new Client for your Gadget API
const client = new Client();
The ai chat gave me this
import { Client } from "@gadget-client/bulk-orders";

// Option 1: Let Gadget handle it automatically (recommended)
// This will automatically use development for dev environments and production for prod
export const api = new Client();

// Option 2: Explicitly specify based on NODE_ENV
export const api = new Client({
environment: process.env.NODE_ENV === "production" ? "production" : "development"
});

// Option 3: If using in browser/frontend code, you can use window.gadgetConfig
export const api = new Client({
environment: window.gadgetConfig?.environment ?? "development"
});
import { Client } from "@gadget-client/bulk-orders";

// Option 1: Let Gadget handle it automatically (recommended)
// This will automatically use development for dev environments and production for prod
export const api = new Client();

// Option 2: Explicitly specify based on NODE_ENV
export const api = new Client({
environment: process.env.NODE_ENV === "production" ? "production" : "development"
});

// Option 3: If using in browser/frontend code, you can use window.gadgetConfig
export const api = new Client({
environment: window.gadgetConfig?.environment ?? "development"
});
Chocci_Milk
Chocci_Milk7mo ago
None of those options will work. You'll just need to remember to switch the env when going live Extensions are sandboxed and don't even allow you to know when you're in dev or not
Jay
JayOP7mo ago
so jus tthis? const api = new Client({ environment: "production", });
Chocci_Milk
Chocci_Milk7mo ago
Yep

Did you find this page helpful?