I've been trying to debug an issue that arose when I added Custom API calls to my Amplify backend. I'm trying to generate a client so I can run queries against my API lambda functions. I've boiled the issue down to the data backend client. Here is some simple code to show where my error is occuring:
`import type { Schema } from "../amplify/data/resource";
import { Amplify } from 'aws-amplify';
import outputs from '../amplify_outputs.json';
import { generateClient } from "aws-amplify/data";
await Amplify.configure(outputs);
const client = generateClient<Schema>();
const fetchUsers = async () => {
const {data, errors} = await client.queries.listUsers();
if(errors) {
console.log('!errors occured! - ' + JSON.stringify(errors));
}
return data;
}
console.log(JSON.stringify(await fetchUsers()));`
This fails with the following error:
Uncaught Error: Client could not be generated. This is likely due to Amplify.configure() not being called prior to generateClient() or because the configuration passed to Amplify.configure() is missing GraphQL provider configuration. at Object.get (aws-amplify_data.js?v=1e467bca:11065:11) at fetchUsers (main.tsx:28:47) at main.tsx:34:34