in common/common-types.ts [66:121]
export async function setDefaultCollection(collectionId: string, doCreate: boolean = false) {
var configEntry = {
configroot: 'config',
configid: 'defaultcollection',
value: collectionId,
};
var response = {
Success: false,
Message: ''
};
if (doCreate) {
// https://dev.to/rmuhlfeldner/how-to-use-an-aws-amplify-graphql-api-with-a-react-typescript-frontend-2g79
const { data } = await callGraphQL<CreateConfigEntryMutation>(
{
query: createConfigEntry,
authMode: GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS,
variables: {
input: configEntry
}
}
);
if (data &&
data.createConfigEntry &&
data.createConfigEntry.value === collectionId) {
response.Success = true;
} else {
response.Success = false;
response.Message = "Unable to create active collection entry";
}
} else {
// https://dev.to/rmuhlfeldner/how-to-use-an-aws-amplify-graphql-api-with-a-react-typescript-frontend-2g79
const { data } = await callGraphQL<UpdateConfigEntryMutation>(
{
query: updateConfigEntry,
authMode: GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS,
variables: {
input: configEntry
}
}
);
if (data &&
data.updateConfigEntry &&
data.updateConfigEntry.value === collectionId) {
response.Success = true;
} else {
response.Success = false;
response.Message = "Unable to update active collection entry";
}
}
return response;
}