diff --git a/dataconnect/connector/connector.yaml b/dataconnect/connector/connector.yaml new file mode 100644 index 00000000..a3273b3f --- /dev/null +++ b/dataconnect/connector/connector.yaml @@ -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 diff --git a/dataconnect/connector/dataconnect.yaml b/dataconnect/connector/dataconnect.yaml deleted file mode 100644 index 881c9248..00000000 --- a/dataconnect/connector/dataconnect.yaml +++ /dev/null @@ -1,13 +0,0 @@ -specVersion: "v1" -serviceId: "krow-workforce" -location: "us-central1" -schema: - source: "./schema" - datasource: - postgresql: - database: "fdcdb" - cloudSql: - instanceId: "krow-workforce-fdc" - # schemaValidation: "STRICT" # STRICT mode makes Postgres schema match Data Connect exactly. - # schemaValidation: "COMPATIBLE" # COMPATIBLE mode makes Postgres schema compatible with Data Connect. -connectorDirs: ["./example"] diff --git a/dataconnect/connector/event/mutations.gql b/dataconnect/connector/event/mutations.gql new file mode 100644 index 00000000..a5a4aa22 --- /dev/null +++ b/dataconnect/connector/event/mutations.gql @@ -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 + } + ) +} \ No newline at end of file diff --git a/dataconnect/connector/event/queries.gql b/dataconnect/connector/event/queries.gql new file mode 100644 index 00000000..1c7103d5 --- /dev/null +++ b/dataconnect/connector/event/queries.gql @@ -0,0 +1,14 @@ +query listEvents @auth(level: USER) { + events { + id + eventName + status + date + isRecurring + recurrenceType + businessId + vendorId + total + requested + } +} \ No newline at end of file diff --git a/dataconnect/dataconnect.yaml b/dataconnect/dataconnect.yaml index 42790982..39e01fdb 100644 --- a/dataconnect/dataconnect.yaml +++ b/dataconnect/dataconnect.yaml @@ -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: ["./connector"] diff --git a/dataconnect/schema/event.gql b/dataconnect/schema/event.gql index bcb3cdc2..4a7b2392 100644 --- a/dataconnect/schema/event.gql +++ b/dataconnect/schema/event.gql @@ -1,6 +1,3 @@ -scalar UUID -scalar Timestamp -scalar JSON enum EventStatus { DRAFT @@ -28,47 +25,14 @@ type Event @table(name: "events") { vendorId: UUID status: EventStatus! date: Timestamp! - shifts: JSON @col(dataType: "jsonb") + shifts: String @col(dataType: "jsonb") total: Float requested: Int - assignedStaff: JSON @col(dataType: "jsonb") - createdDate: Timestamp @default(expr: "now()") - updatedDate: Timestamp @updatedAt + assignedStaff: String @col(dataType: "jsonb") + createdDate: Timestamp @default(expr: "request.time") + updatedDate: Timestamp @default(expr: "request.time") 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 -} -query listEvents @auth(level: USER) { - events { - id - eventName - status - date - isRecurring - recurrenceType - businessId - vendorId - total - requested - } -} - -mutation createEvent($input: CreateEventInput!) @auth(level: USER) { - event_insert(data: $input) { - id - } -}