forked from ogjr80/firebase-function
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.js
More file actions
250 lines (213 loc) · 4.77 KB
/
schema.js
File metadata and controls
250 lines (213 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
const { gql } = require("graphql-tag");
const typeDefs = gql`
"""
User Types Definitions
"""
type User {
userId: ID!
email: String!
displayName: String!
profileImageURL: String
role: Role!
dateCreated: String!
farms: [Farm!]!
}
enum Role {
FARMER
AGRONOMIST
RESEARCHER
OTHER
}
"""
Farmer Type Definitions
"""
type Farm {
farmId: ID!
userId: ID!
user: User!
name: String!
location: Location!
size: Float!
unit: Unit!
description: String
dateCreated: String!
crops: [Crop!]!
livestocks: [Livestock!]!
weatherData: [WeatherData!]!
}
enum Unit {
HECTARES
ACRES
}
type Location {
latitude: Float!
longitude: Float!
}
""" CROP Type """
type Crop {
cropId: ID!
farm: Farm!
user: User!
type: String!
stage: CropStage!
plantingDate: String!
harvestDate: String
healthStatus: String!
dateCreated: String!
}
enum CropStage {
GERMINATION
FLOWERING
HARVEST
}
"""Livestock Types """
type Livestock {
livestockId: ID!
farmId: ID!
userId: ID!
farm: Farm!
user: User!
type: String!
quantity: Int!
healthStatus: String!
location: String
dateCreated: String!
}
""" WeatherData Types """
type WeatherData {
weatherDataId: ID!
userId: ID!
farmId: ID!
farm: Farm!
date: String!
temperature: Float!
humidity: Float!
rainfall: Float!
windSpeed: Float!
}
type Query {
""" User query """
getUser(userId: ID!): User
getUsers: [User!]!
"""Farm Query Definition """
getFarm(farmId: ID!): Farm
getFarms: [Farm!]!
getFarmsByUserId(userId: ID!): [Farm!]!
"""CROP Query Definition """
getCrop(cropId: ID!): Crop!
getCrops: [Crop!]!
"""Livestock Query Definition """
getLivestock(livestockId: ID!): Livestock!
getAllLivestock: [Livestock!]!
""" WeatherData Query Definitions """
getAllWeatherData: [WeatherData!]!
getWeatherData(weatherDataId: ID!): WeatherData!
getWeatherDataByFarmId(farmId: ID!): [WeatherData!]!
}
type Mutation {
""" User Mutation"""
createUser(input: CreateUserInput!): User!
updateUser(userId: ID!, input: UpdateUserInput!): User!
""" Farm Mutations """
createFarm(input: CreateFarmInput!): Farm!
updateFarm(farmId: ID!, input: UpdateFarmInput!): Farm!
""" CROP Mutation """
createCrop(input: CropInput!): Crop!
updateCrop(cropId: ID!, input: CropUpdateInput!): Crop!
deleteCrop(cropId:ID!): Crop!
""" Livestock Mutation """
createLivestock(input: LivestockInput!): Livestock!
updateLivestock(livestockId: ID!, input: LivestockUpdateInput!): Livestock!
deleteLivestock(livestockId: ID!): Livestock!
""" WeatherData Mutation """
createWeatherData(input: WeatherDataInput!): WeatherData!
updateWeatherData(weatherDataId: ID!, input: WeatherDataUpdateInput!): WeatherData!
}
""" User Inputs """
input CreateUserInput {
email: String!
displayName: String!
profileImageURL: String
role: Role!
}
input UpdateUserInput {
email: String
displayName: String
profileImageURL: String
role: Role
}
""" Farm Inputs """
input CreateFarmInput {
userId: ID!
name: String!
location: LocationInput!
size: Float!
unit: Unit!
description: String
}
input UpdateFarmInput {
name: String
location: LocationInput
size: Float
unit: Unit
description: String
}
input LocationInput {
latitude: Float!
longitude: Float!
}
""" CROP Inputs """
input CropInput {
farmId: ID!
userId: ID!
type: String!
stage: CropStage!
plantingDate: String!
harvestDate: String
healthStatus: String!
}
input CropUpdateInput {
farmId: ID
userId: ID
type: String
stage: CropStage
plantingDate: String
harvestDate: String
healthStatus: String
}
""" Livestock Inputs """
input LivestockInput {
farmId: ID!
userId: ID!
type: String!
quantity: Int!
healthStatus: String!
location: String
}
input LivestockUpdateInput {
farmId: ID
userId: ID
type: String
quantity: Int
healthStatus: String
location: String
}
""" WeatherData Inputs """
input WeatherDataInput {
farmId: ID!
date: String!
temperature: Float!
humidity: Float!
rainfall: Float!
windSpeed: Float!
}
input WeatherDataUpdateInput {
farmId: ID
date: String
temperature: Float
humidity: Float
rainfall: Float
windSpeed: Float
}
`
module.exports = typeDefs;