Guest User

Untitled

a guest
Aug 16th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. //
  2. // Queryables.swift
  3. // DataSiteOne
  4. //
  5. // Created by Bollbach, Alexander on 7/26/18.
  6. // Copyright © 2018 Merrill Corporation. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10.  
  11. extension Query: GQLRequest {
  12.  
  13. var hashValue: Int { return description.hashValue }
  14.  
  15. var description: String {
  16. switch self {
  17. case .mutation(let mutations): return "mutation { \(join(mutations)) }"
  18. case .getCurrentUser(let fields): return "query { getCurrentUser { \(join(fields)) } }"
  19. case .grid(let projectId,
  20. let parentId,
  21. let fields): return "query { getGridLevel(projectId: \"\(projectId)\", parentId: \"\(parentId)\") { \(join(fields)) } }"
  22. }
  23. }
  24. }
  25. extension Query.JWT: GQLRequest {
  26.  
  27. var hashValue: Int { return description.hashValue }
  28.  
  29. var description: String {
  30. return "jwt"
  31. }
  32. }
  33. extension Query.Mutation: GQLRequest {
  34.  
  35. var hashValue: Int { return description.hashValue }
  36.  
  37. var description: String {
  38. switch self {
  39. case .userGatewayJwt(let email,
  40. let password,
  41. let jwt): return "userGatewayJwt(email: \"\(email)\", password: \"\(password)\") { \(join(jwt)) }"
  42. }
  43. }
  44. }
  45. extension Query.User: GQLRequest {
  46.  
  47. var hashValue: Int { return description.hashValue }
  48.  
  49. var description: String {
  50. switch self {
  51. case .projects(let fields): return "projects { \(join(fields)) }"
  52. }
  53. }
  54. }
  55. extension Query.Project: GQLRequest {
  56.  
  57. var hashValue: Int { return description.hashValue }
  58.  
  59. var description: String {
  60. switch self {
  61. case .projectId: return "projectId"
  62. case .name: return "name"
  63. }
  64. }
  65. }
  66.  
  67. extension Query.Grid: GQLRequest {
  68.  
  69. var hashValue: Int { return description.hashValue }
  70.  
  71. var description: String {
  72. switch self {
  73. case let .children(fields): return "children { \(join(fields)) }"
  74. case let .breadcrumbs(fields): return "breadcrumbs { \(join(fields)) }"
  75. }
  76. }
  77. }
  78. extension Query.Grid.Breadcrumb: GQLRequest {
  79.  
  80. var hashValue: Int { return description.hashValue }
  81.  
  82. var description: String {
  83. switch self {
  84. case .id: return "id"
  85. case .name: return "name"
  86. case .type: return "type"
  87. }
  88. }
  89. }
  90. extension Query.Grid.Node: GQLRequest {
  91.  
  92. var hashValue: Int { return description.hashValue }
  93.  
  94. var description: String {
  95. switch self {
  96. case .id: return "id"
  97. case .name: return "name"
  98. case .displayIndex: return "displayIndex"
  99. case .type: return "type"
  100. case .createdDate: return "createDate"
  101. }
  102. }
  103. }
Add Comment
Please, Sign In to add comment