Good day, I’m trying to set up my own field validation using Lambda Webhooks for my entity. Here is the approximate code that I have:
@auth<ExtendedGraphQLEventFields, BlacklistFields>()
static async add({
event,
authHeader,
respondWith,
}: Omit<WebHookGraphQLEvent, 'authHeader'> & {
event: { add: addEventDgraph };
authHeader: ExtendedAuthHeaderField;
respondWith: (r: ResolverResponse) => void;
}): Promise<void> {
try {
const userRole: string =
authHeader?.decodedToken?.['https://dgraph-app-frs-claims']?.role ??
Roles.manager;
console.log(userRole);
const input = event?.add?.input;
if (input) {
interface IMember {
active: boolean;
isIndexed: boolean;
name: string;
slug: string;
url: string & tags.Format<'url'>;
}
const validation: typia.IValidation<IMember> = typia.validate<IMember>(
input[0]
);
if (!validation.success) {
return respondWith([{ errors: ['Validation Error'] }]);
}
}
} catch (e) {
console.error(e);
}
}
I searched for answers on the forum, but I’m not satisfied with the options with @custom or @lambda by field. As far as I understood, this Lambda Webhooks are executed after saving data in Dgraph. Has anyone encountered the same issue and found a solution?