git.js 845 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const gql = require('graphql-tag')
  2. // Connectors
  3. const git = require('../connectors/git')
  4. exports.types = gql`
  5. extend type Query {
  6. fileDiffs: [FileDiff]
  7. }
  8. extend type Mutation {
  9. gitCommit (message: String!): Boolean
  10. }
  11. type FileDiff {
  12. id: ID!
  13. from: String
  14. to: String
  15. new: Boolean
  16. deleted: Boolean
  17. binary: Boolean
  18. chunks: [FileDiffChunk]
  19. }
  20. type FileDiffChunk {
  21. changes: [FileDiffChange]
  22. oldStart: Int
  23. oldLines: Int
  24. newStart: Int
  25. newLines: Int
  26. }
  27. type FileDiffChange {
  28. type: FileDiffChangeType
  29. ln: Int
  30. ln1: Int
  31. ln2: Int
  32. content: String
  33. normal: Boolean
  34. }
  35. enum FileDiffChangeType {
  36. normal
  37. add
  38. del
  39. }
  40. `
  41. exports.resolvers = {
  42. Query: {
  43. fileDiffs: (root, args, context) => git.getDiffs(context)
  44. },
  45. Mutation: {
  46. gitCommit: (root, { message }, context) => git.commit(message, context)
  47. }
  48. }