'I can't figure where is the problem with my graphql request
I'm getting bad request code every time i try to send data query in graphql,
and I can't figure if the problem from the resolver or from the input,
below is the resolver :
const addTranslationTableAdminResolver = async (args, context, info) => {
checkAuth(context);
const videocardId = args.input.videoCardId;
const videoLink = args.input.videoLink;
const orgId = args.input.orgId;
await context.dao.createTranslationTable({
id,
orgId,
videocardId,
dateTime,
videoLink,
});
return {
statusMessage: 'SUCCESS',
};
};
and the data-object access as below:
const createTranslationTable = async ({ orgId, videocardId, videoLink }) => {
const queryString = `INSERT INTO translation_table (org_id, video_id,request_date,video_link)
VALUES ($1, $2, $3, $4) RETURNING *`;
const dateTime = new Date();
const values = [orgId, videocardId, dateTime, videoLink];
const result = await query(queryString, values);
if (result && result.rows.length === 1) {
return getAllTranslationObject(result.rows[0]);
}
};
when I'm trying to send data query i'm getting the same error as above.
const createTransaltionVideoCard = (orgId, videoCardId, videoLink) => {
return gqBackOfficeClient.mutate({
mutation: gql`
mutation {
createTranslationTable(input: {
orgId: ${orgId},
videocardId: ${videoCardId},
videoLink :"${videoLink}"
}) {
statusMessage
}
}
`,
});
};
const handleTranslationButtonClick = (orgId, videoCardId, videoLink) => {
setIsTranslationButtonClicked(true);
createTransaltionVideoCard({
orgId,
videoCardId,
videoLink,
}).then((res) => {
console.log(res);
});
};
Solution 1:[1]
just to update , solved this issue, it was a problem with resolvers, and now its working fine –
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MKilou |