I'm following the documentation to read data from the gen 2 amplify resource file, and it works fine locally, but when it's actually deployed I run into seemingly random problems where the client object doesn't have any models loaded.
I've included example code:
let client = generateClient<Schema>();
const fetchUser = async ({
email,
serverClient,
}: FetchUserProps): Promise<User | null> => {
try {
client = serverClient || client;
const usersData = await client.models.User.list({
filter: { email: { eq: email } },
selectionSet: [
"id",
"email",
...
Typescript confirms all my types are correct, and it works fine in a dev environment, but when hosted by Amplify I get an error when calling this list function. Some debugging indicates that the client object simply has no models within it at the time this is called.
I don't understand this system deeply enough to figure out the problem, could someone help me with some additional context?