2021-07-13 22:54:49 +03:00
|
|
|
// Utility to match GraphQL mutation based on the query name
|
|
|
|
export const hasQuery = (req: any, queryName: string) => {
|
|
|
|
const { body } = req
|
2022-12-21 02:08:20 +03:00
|
|
|
return Object.prototype.hasOwnProperty.call(body, 'query') && body.query.includes(queryName)
|
2021-07-13 22:54:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Alias query if queryName matches
|
|
|
|
export const aliasQuery = (req: any, queryName: string) => {
|
|
|
|
if (hasQuery(req, queryName)) {
|
|
|
|
req.alias = `${queryName}Query`
|
|
|
|
}
|
|
|
|
}
|