You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
830 B

  1. const _ = require('lodash')
  2. const fs = require('fs')
  3. // const gqlTools = require('graphql-tools')
  4. const path = require('path')
  5. const autoload = require('auto-load')
  6. /* global WIKI */
  7. WIKI.logger.info(`Loading GraphQL Schema...`)
  8. // Schemas
  9. let typeDefs = []
  10. let schemas = fs.readdirSync(path.join(WIKI.SERVERPATH, 'graph/schemas'))
  11. schemas.forEach(schema => {
  12. typeDefs.push(fs.readFileSync(path.join(WIKI.SERVERPATH, `graph/schemas/${schema}`), 'utf8'))
  13. })
  14. // Resolvers
  15. let resolvers = {}
  16. const resolversObj = _.values(autoload(path.join(WIKI.SERVERPATH, 'graph/resolvers')))
  17. resolversObj.forEach(resolver => {
  18. _.merge(resolvers, resolver)
  19. })
  20. // const Schema = gqlTools.makeExecutableSchema({
  21. // typeDefs,
  22. // resolvers
  23. // })
  24. WIKI.logger.info(`GraphQL Schema: [ OK ]`)
  25. module.exports = {
  26. typeDefs,
  27. resolvers
  28. }