Merge pull request #51 from Oloodi/5-backend-define-and-deploy-event-schema
for the task 5, I defined and deployed event schema with the configuration of dataconnect
This commit is contained in:
8
dataconnect/connector/connector.yaml
Normal file
8
dataconnect/connector/connector.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
connectorId: krow-connector
|
||||
generate:
|
||||
javascriptSdk:
|
||||
- outputDir: ../../frontend-web/src/dataconnect-generated
|
||||
package: "@dataconnect/generated"
|
||||
packageJsonDir: ../../frontend-web
|
||||
react: true
|
||||
angular: false
|
||||
29
dataconnect/connector/event/mutations.gql
Normal file
29
dataconnect/connector/event/mutations.gql
Normal file
@@ -0,0 +1,29 @@
|
||||
mutation CreateEvent(
|
||||
$eventName: String!,
|
||||
$isRecurring: Boolean!,
|
||||
$recurrenceType: RecurrenceType,
|
||||
$businessId: UUID!,
|
||||
$vendorId: UUID,
|
||||
$status: EventStatus!,
|
||||
$date: Timestamp!,
|
||||
$shifts: String,
|
||||
$total: Float,
|
||||
$requested: Int,
|
||||
$assignedStaff: String
|
||||
) @auth(level: USER) {
|
||||
event_insert(
|
||||
data: {
|
||||
eventName: $eventName
|
||||
isRecurring: $isRecurring
|
||||
recurrenceType: $recurrenceType
|
||||
businessId: $businessId
|
||||
vendorId: $vendorId
|
||||
status: $status
|
||||
date: $date
|
||||
shifts: $shifts
|
||||
total: $total
|
||||
requested: $requested
|
||||
assignedStaff: $assignedStaff
|
||||
}
|
||||
)
|
||||
}
|
||||
14
dataconnect/connector/event/queries.gql
Normal file
14
dataconnect/connector/event/queries.gql
Normal file
@@ -0,0 +1,14 @@
|
||||
query listEvents @auth(level: USER) {
|
||||
events {
|
||||
id
|
||||
eventName
|
||||
status
|
||||
date
|
||||
isRecurring
|
||||
recurrenceType
|
||||
businessId
|
||||
vendorId
|
||||
total
|
||||
requested
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
specVersion: "v1"
|
||||
serviceId: "krow-workforce"
|
||||
serviceId: "krow-workforce-db"
|
||||
location: "us-central1"
|
||||
schema:
|
||||
source: "./schema"
|
||||
datasource:
|
||||
postgresql:
|
||||
database: "fdcdb"
|
||||
database: "krow_db"
|
||||
cloudSql:
|
||||
instanceId: "krow-workforce-fdc"
|
||||
instanceId: "krow-sql"
|
||||
# schemaValidation: "STRICT" # STRICT mode makes Postgres schema match Data Connect exactly.
|
||||
# schemaValidation: "COMPATIBLE" # COMPATIBLE mode makes Postgres schema compatible with Data Connect.
|
||||
connectorDirs: ["./example"]
|
||||
connectorDirs: ["./connector"]
|
||||
|
||||
38
dataconnect/schema/event.gql
Normal file
38
dataconnect/schema/event.gql
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
enum EventStatus {
|
||||
DRAFT
|
||||
ACTIVE
|
||||
PENDING
|
||||
ASSIGNED
|
||||
CONFIRMED
|
||||
COMPLETED
|
||||
CANCELED
|
||||
}
|
||||
|
||||
enum RecurrenceType {
|
||||
SINGLE
|
||||
DATE_RANGE
|
||||
SCATTER
|
||||
}
|
||||
|
||||
type Event @table(name: "events") {
|
||||
|
||||
id: UUID! @default(expr: "uuidV4()")
|
||||
eventName: String!
|
||||
isRecurring: Boolean!
|
||||
recurrenceType: RecurrenceType
|
||||
businessId: UUID!
|
||||
vendorId: UUID
|
||||
status: EventStatus!
|
||||
date: Timestamp!
|
||||
shifts: String @col(dataType: "jsonb")
|
||||
total: Float
|
||||
requested: Int
|
||||
assignedStaff: String @col(dataType: "jsonb")
|
||||
createdDate: Timestamp @default(expr: "request.time")
|
||||
updatedDate: Timestamp @default(expr: "request.time")
|
||||
createdBy: String
|
||||
|
||||
}
|
||||
|
||||
|
||||
62
firebase/dataconnect/schema/event.gpl
Normal file
62
firebase/dataconnect/schema/event.gpl
Normal file
@@ -0,0 +1,62 @@
|
||||
scalar UUID
|
||||
scalar Timestamp
|
||||
scalar JSON
|
||||
|
||||
enum EventStatus {
|
||||
DRAFT
|
||||
ACTIVE
|
||||
PENDING
|
||||
ASSIGNED
|
||||
CONFIRMED
|
||||
COMPLETED
|
||||
CANCELED
|
||||
}
|
||||
|
||||
enum RecurrenceType {
|
||||
SINGLE
|
||||
DATE_RANGE
|
||||
SCATTER
|
||||
}
|
||||
|
||||
type Event @table(name: "events") {
|
||||
|
||||
id: UUID! @col(name: "id", primaryKey: true) @default(expr: "uuidV4()")
|
||||
eventName: String!
|
||||
isRecurring: Boolean!
|
||||
recurrenceType: RecurrenceType
|
||||
businessId: UUID!
|
||||
vendorId: UUID
|
||||
status: EventStatus!
|
||||
date: Timestamp!
|
||||
shifts: JSON @col(dataType: "jsonb")
|
||||
total: Float
|
||||
requested: Int
|
||||
assignedStaff: JSON @col(dataType: "jsonb")
|
||||
createdDate: Timestamp @default(expr: "now()")
|
||||
updatedDate: Timestamp @updateAt
|
||||
createdBy: String
|
||||
|
||||
}
|
||||
|
||||
input CreateEventInput {
|
||||
eventName: String!
|
||||
isRecurring: Boolean!
|
||||
recurrenceType: RecurrenceType
|
||||
businessId: UUID!
|
||||
vendorId: UUID
|
||||
status: EventStatus!
|
||||
date: Timestamp!
|
||||
shifts: JSON
|
||||
total: Float
|
||||
requested: Int
|
||||
assignedStaff: JSON
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createEvent(input: CreateEventInput!): Event @auth
|
||||
}
|
||||
|
||||
type Query {
|
||||
listEvents: [Event!] @auth
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user