Created
April 27, 2021 15:13
-
-
Save renegoretzka/7fe93b5615c56746f3bcad6d08abf98e to your computer and use it in GitHub Desktop.
AWS Amplify - AppSync Schema Suggestion for BlueHyz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User | |
@model | |
@auth( | |
rules: [ | |
{ allow: owner, ownerField: "id" } | |
{ allow: groups, groups: ["admin"] } | |
] | |
) { | |
id: ID! | |
name: String | |
bookings: [Booking] @connection(keyName: "bookingsByUser", fields: ["id"]) | |
} | |
type Booking | |
@model | |
@auth( | |
rules: [ | |
{ allow: owner, ownerField: "userID" } | |
{ allow: groups, groups: ["admin"] } | |
] | |
) | |
@key(name: "bookingsByUser", fields: ["userID", "createdAt"]) { | |
id: ID! | |
userID: ID | |
user: User @connection(fields: ["userID"]) | |
reservations: [Reservation] | |
@connection(keyName: "reservationsByBooking", fields: ["id"]) | |
createdAt: AWSDateTime | |
updatedAt: AWSDateTime | |
} | |
type Reservation | |
@model | |
@auth( | |
rules: [ | |
{ allow: owner, ownerField: "userID" } | |
{ allow: groups, groups: ["admin"] } | |
] | |
) | |
@key(name: "reservationsByBooking", fields: ["bookingID"]) { | |
id: ID! | |
userID: ID! | |
user: User @connection(fields: ["userID"]) | |
bookingID: ID! | |
booking: Booking @connection(fields: ["bookingID"]) | |
capacityID: ID! | |
capacity: Capacity @connection(fields: ["capacityID"]) | |
guests: [Guest] | |
} | |
type Guest { | |
name: String | |
} | |
type Hotel | |
@model | |
@auth( | |
rules: [ | |
{ allow: groups, groups: ["admin"] } | |
{ allow: private, operations: [read] } | |
{ allow: public, operations: [read], provider: iam } | |
] | |
) { | |
id: ID! | |
name: String | |
address: String | |
capacities: [Capacity] | |
@connection(keyName: "capacitiesByHotel", fields: ["id"]) | |
rooms: [Room] @connection(keyName: "roomsByHotel", fields: ["id"]) | |
} | |
type Capacity | |
@model | |
@auth( | |
rules: [ | |
{ allow: groups, groups: ["admin"] } | |
{ allow: private, operations: [read] } | |
{ allow: public, operations: [read], provider: iam } | |
] | |
) | |
@key(name: "capacitiesByHotel", fields: ["hotelID", "date"]) | |
@key(name: "capacitiesByRoom", fields: ["roomID", "date"]) | |
@key(name: "capacitiesByBooking", fields: ["bookingID", "date"]) { | |
id: ID! | |
date: AWSDateTime | |
hotelID: ID! | |
hotel: Hotel @connection(fields: ["hotelID"]) | |
roomID: ID! | |
room: Room @connection(fields: ["roomID"]) | |
reservationID: ID | |
reservation: Reservation @connection(fields: ["reservationID"]) | |
} | |
type Room | |
@model | |
@auth( | |
rules: [ | |
{ allow: groups, groups: ["admin"] } | |
{ allow: private, operations: [read] } | |
{ allow: public, operations: [read], provider: iam } | |
] | |
) | |
@key(name: "roomsByHotel", fields: ["hotelID", "type"]) { | |
id: ID! | |
description: String | |
type: RoomTypeEnum | |
maxGuests: Int | |
hotelID: ID! | |
hotel: Hotel @connection(fields: ["hotelID"]) | |
capacities: [Capacity] | |
@connection(keyName: "capacitiesByRoom", fields: ["id"]) | |
} | |
enum RoomTypeEnum { | |
SINGLE | |
COUPLE | |
SOMETHINGELSE | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment