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.

41 lines
1.1 KiB

  1. const _ = require('lodash')
  2. const { createApolloFetch } = require('apollo-fetch')
  3. /* global WIKI */
  4. module.exports = async () => {
  5. WIKI.logger.info(`Fetching latest updates from Graph endpoint...`)
  6. try {
  7. const apollo = createApolloFetch({
  8. uri: WIKI.config.graphEndpoint
  9. })
  10. const resp = await apollo({
  11. query: `query ($channel: ReleaseChannel!, $version: String!) {
  12. releases {
  13. checkForUpdates(channel: $channel, version: $version) {
  14. channel
  15. version
  16. releaseDate
  17. minimumVersionRequired
  18. minimumNodeRequired
  19. }
  20. }
  21. }`,
  22. variables: {
  23. channel: WIKI.config.channel,
  24. version: WIKI.version
  25. }
  26. })
  27. const info = _.get(resp, 'data.releases.checkForUpdates', false)
  28. if (info) {
  29. WIKI.system.updates = info
  30. }
  31. WIKI.logger.info(`Fetching latest updates from Graph endpoint: [ COMPLETED ]`)
  32. } catch (err) {
  33. WIKI.logger.error(`Fetching latest updates from Graph endpoint: [ FAILED ]`)
  34. WIKI.logger.error(err.message)
  35. }
  36. }