I am trying to query Amplify to get data from a graphQl endpoint. I am sending the data to the backend successfully. Below is the request from GraphQL
const getFixtures = async () => {
const clubProfile = await DataStore.query(ClubProfile, c => c.id(userUuid));
setFixturesListData(clubProfile.fixtures);
console.log('fixtures here', clubProfile);
};
The output of the console is: fixtures here [] (just an empty array)
The model is:
export declare class ClubProfile {
readonly id: string;
readonly club_email?: string | null;
readonly club_name?: string | null;
readonly club_number?: string | null;
readonly club_description?: string | null;
readonly club_website?: string | null;
readonly club_teams?: string | null;
readonly createdAt?: string | null;
readonly updatedAt?: string | null;
constructor(init: ModelInit<ClubProfile, ClubProfileMetaData>);
static copyOf(source: ClubProfile, mutator: (draft: MutableModel<ClubProfile, ClubProfileMetaData>) => MutableModel<ClubProfile, ClubProfileMetaData> | void): ClubProfile;
}
I am trying different options and getting no success.
When I send the data to the backend:
const clubInfo = async () => {
let uuid = customerInfo.customerInfo.attributes.sub;
const newClub = {
id: uuid,
club_name: clubName,
club_email: clubEmail,
club_number: clubPhone,
club_location: clubLocation,
club_website: 'https://www.clubWebsite.com',
club_teams: {clubTeams},
club_description: 'clubDescription',
};
await DataStore.save(new ClubProfile(newClub));
console.log('newClub', newClub);
setNewClub(newClub);
};
clubInfo();
}