Skip to content

Instantly share code, notes, and snippets.

@duwerq
Created February 11, 2021 18:10
Show Gist options
  • Save duwerq/b941cac09760c36856c2413705087540 to your computer and use it in GitHub Desktop.
Save duwerq/b941cac09760c36856c2413705087540 to your computer and use it in GitHub Desktop.
type GPS {
lon: Float
lat: Float
}
type Establishment
@model
@auth(rules: [{ allow: public, provider: iam }])
@key(fields: ["ownerId", "id"]) {
id: ID!
ownerId: ID!
owner: User
name: String!
gps: GPS
street: String
city: String
state: String
zipcode: String
neighborhood: String
phone: String
email: String
placeID: String!
phoneNumber: String
likeCount: Int
reviews: [Review]
userLikes: [EstablishmentLike] @connection(fields: ["id"])
}
type EstablishmentLike
@model(subscriptions: { level: public })
@auth(rules: [{ allow: public, provider: iam }])
@key(fields: ["establishmentId", "createdAt"])
@key(
name: "establishmentLikesByUser"
fields: ["userId", "createdAt"]
queryField: "getEstablishmentLikesByUser"
) {
establishmentId: ID!
userId: ID!
@auth(rules: [{ allow: owner, ownerField: "userId", identityClaim: "sub" }])
createdAt: AWSTimestamp!
establishment: Establishment @connection(fields: ["establishmentId"])
user: User @connection(fields: ["userId"])
establishmentName: String
}
type CheckIn
@model(subscriptions: { level: public })
@auth(rules: [{ allow: public, provider: iam }])
@key(fields: ["establishmentId", "createdAt"])
@key(
name: "userCheckins"
fields: ["userId", "createdAt"]
queryField: "getUserCheckins"
) {
establishmentId: ID!
userId: ID!
@auth(rules: [{ allow: owner, ownerField: "userId", identityClaim: "sub" }])
createdAt: AWSTimestamp!
establishmentName: String
establishment: Establishment @connection(fields: ["establishmentId"])
user: User @connection(fields: ["userId"])
}
type EstablishmentFollow
@model
@key(fields: ["establishmentId", "userId"])
@key(
name: "establishmentsFollowedByUser"
fields: ["userId", "establishmentId"]
queryField: "getEstablishmentsFollowedByUser"
) {
establishmentId: ID!
userId: ID! # user.id
establishment: Establishment @connection(fields: ["establishmentId"])
user: User @connection(fields: ["userId"])
}
type Review
@model(subscriptions: { level: public })
@auth(rules: [{ allow: public, provider: iam }])
@key(fields: ["establishmentId", "createdAt"])
@key(
name: "userCheckins"
fields: ["userId", "createdAt"]
queryField: "getUserCheckins"
) {
establishmentId: ID!
userId: ID!
@auth(rules: [{ allow: owner, ownerField: "userId", identityClaim: "sub" }])
createdAt: AWSTimestamp!
establishmentName: String
comments: String
image: [String]
rating: Int
establishment: Establishment @connection(fields: ["establishmentId"])
user: User @connection(fields: ["userId"])
}
type User
@model(mutations: { update: "updateUser", delete: "deleteUser" })
@auth(
rules: [
{
allow: owner
ownerField: "id"
identityClaim: "sub"
operations: [update, delete, read]
}
]
)
@key(fields: ["pk_id", "id"]) {
pk_id: ID!
id: ID!
firstName: String
lastName: String
userName: String
birthdate: String
gender: String
description: String
ownerOf: [Establishment]
createdAt: AWSDateTime
lastUpdated: AWSDateTime
profilePicture: String
followers: [UserFollow] @connection(keyName: "followers", fields: ["id"])
followed: [UserFollow] @connection(fields: ["id"])
establishmentLikes: [EstablishmentLike]
@connection(keyName: "establishmentLikesByUser", fields: ["id"])
}
type UserFollow
@model
@key(fields: ["id", "userFollowedId"])
@key(
name: "followers"
fields: ["userFollowedId", "id"]
queryField: "getFollowers"
) {
id: ID! # user.id
userFollower: User @connection(fields: ["id"])
userFollowedId: ID! # user.id I'm following
userFollowed: User @connection(fields: ["userFollowedId"])
}
enum UserType {
consumer
owner
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment