feat: add singleByPath GraphQL resolver (#6011)
Co-authored-by: k k <kleangseu@yahoo.com>
This commit is contained in:
parent
1da80eaab8
commit
0d914b061e
@ -170,6 +170,30 @@ module.exports = {
|
||||
throw new WIKI.Error.PageNotFound()
|
||||
}
|
||||
},
|
||||
async singleByPath(obj, args, context, info) {
|
||||
let page = await WIKI.models.pages.getPageFromDb({
|
||||
path: args.path,
|
||||
locale: args.locale,
|
||||
});
|
||||
if (page) {
|
||||
if (WIKI.auth.checkAccess(context.req.user, ['manage:pages', 'delete:pages'], {
|
||||
path: page.path,
|
||||
locale: page.localeCode
|
||||
})) {
|
||||
return {
|
||||
...page,
|
||||
locale: page.localeCode,
|
||||
editor: page.editorKey,
|
||||
scriptJs: page.extra.js,
|
||||
scriptCss: page.extra.css
|
||||
}
|
||||
} else {
|
||||
throw new WIKI.Error.PageViewForbidden()
|
||||
}
|
||||
} else {
|
||||
throw new WIKI.Error.PageNotFound()
|
||||
}
|
||||
},
|
||||
/**
|
||||
* FETCH TAGS
|
||||
*/
|
||||
|
@ -46,6 +46,11 @@ type PageQuery {
|
||||
id: Int!
|
||||
): Page @auth(requires: ["read:pages", "manage:system"])
|
||||
|
||||
singleByPath(
|
||||
path: String!
|
||||
locale: String!
|
||||
): Page @auth(requires: ["read:pages", "manage:system"])
|
||||
|
||||
tags: [PageTag]! @auth(requires: ["manage:system", "read:pages"])
|
||||
|
||||
searchTags(
|
||||
|
Loading…
Reference in New Issue
Block a user