block.mjs 649 B

1234567891011121314151617181920212223242526
  1. import { generateError, generateSuccess } from '../../helpers/graph.mjs'
  2. export default {
  3. Query: {
  4. async blocks (obj, args, context) {
  5. return WIKI.db.blocks.query().where({
  6. siteId: args.siteId
  7. })
  8. }
  9. },
  10. Mutation: {
  11. async setBlocksState(obj, args, context) {
  12. try {
  13. if (!WIKI.auth.checkAccess(context.req.user, ['manage:blocks'])) {
  14. throw new Error('ERR_FORBIDDEN')
  15. }
  16. // TODO: update blocks state
  17. return {
  18. operation: generateSuccess('Blocks state updated successfully')
  19. }
  20. } catch (err) {
  21. return generateError(err)
  22. }
  23. }
  24. }
  25. }