This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
imagini/graph/schema.graphqls

385 lines
8.5 KiB
GraphQL
Raw Normal View History

2021-02-02 20:34:10 +00:00
# https://gqlgen.com/reference/scalars/
scalar Time
scalar Upload
# https://gqlgen.com/reference/directives/
2021-02-03 03:55:35 +00:00
directive @hasMinRole(role: Role!) on FIELD_DEFINITION
2021-02-04 20:31:07 +00:00
directive @isPrivate on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
2021-02-02 20:34:10 +00:00
directive @meta(
gorm: String,
) on OBJECT | FIELD_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ENUM | INPUT_OBJECT | ARGUMENT_DEFINITION
enum Role {
Admin
User
}
enum DeviceType {
iOS
Android
Chrome
Firefox
InternetExplorer
Edge
Safari
Unknown
}
enum AuthType {
Local
LDAP
}
2021-02-09 00:42:20 +00:00
enum OrderDirection {
ASC
DESC
}
2021-02-03 03:55:35 +00:00
# ------------------------------------------------------------
# ---------------------- Authentication ----------------------
# ------------------------------------------------------------
enum AuthResult {
Success
Failure
}
type AuthResponse {
2021-02-04 20:31:07 +00:00
result: AuthResult!
device: Device
error: String
2021-02-03 03:55:35 +00:00
}
2021-02-02 20:34:10 +00:00
# ------------------------------------------------------------
# ----------------------- Type Filters -----------------------
# ------------------------------------------------------------
input TimeFilter {
equalTo: Time
notEqualTo: Time
lessThan: Time
lessThanOrEqualTo: Time
2021-02-08 17:41:58 +00:00
greaterThan: Time
greaterThanOrEqualTo: Time
2021-02-02 20:34:10 +00:00
}
input IntFilter {
equalTo: Int
notEqualTo: Int
lessThan: Int
lessThanOrEqualTo: Int
2021-02-08 17:41:58 +00:00
greaterThan: Int
greaterThanOrEqualTo: Int
2021-02-02 20:34:10 +00:00
}
input FloatFilter {
equalTo: Float
notEqualTo: Float
lessThan: Float
lessThanOrEqualTo: Float
2021-02-08 17:41:58 +00:00
greaterThan: Float
greaterThanOrEqualTo: Float
2021-02-02 20:34:10 +00:00
}
input BooleanFilter {
equalTo: Boolean
notEqualTo: Boolean
}
input IDFilter {
equalTo: ID
notEqualTo: ID
}
input StringFilter {
equalTo: String
notEqualTo: String
2021-02-08 17:41:58 +00:00
startsWith: String
notStartsWith: String
endsWith: String
notEndsWith: String
contains: String
notContains: String
2021-02-02 20:34:10 +00:00
}
input RoleFilter {
equalTo: Role
notEqualTo: Role
}
input DeviceTypeFilter {
equalTo: DeviceType
notEqualTo: DeviceType
}
input AuthTypeFilter {
equalTo: AuthType
notEqualTo: AuthType
}
# ------------------------------------------------------------
# -------------------- Object Definitions --------------------
# ------------------------------------------------------------
2021-02-06 03:01:51 +00:00
type User {
id: ID! @meta(gorm: "primaryKey;not null")
createdAt: Time
updatedAt: Time
email: String! @meta(gorm: "not null;unique")
username: String! @meta(gorm: "not null;unique")
firstName: String
lastName: String
role: Role! @meta(gorm: "default:User;not null")
authType: AuthType! @meta(gorm: "default:Local;not null")
password: String @isPrivate
devices: [Device!] @meta(gorm: "foreignKey:UserID")
mediaItems: [MediaItem!] @meta(gorm: "foreignKey:UserID")
}
2021-02-02 20:34:10 +00:00
type Device {
2021-02-04 10:16:13 +00:00
id: ID! @meta(gorm: "primaryKey;not null")
2021-02-02 20:34:10 +00:00
createdAt: Time
updatedAt: Time
name: String! @meta(gorm: "not null")
type: DeviceType! @meta(gorm: "default:Unknown;not null")
2021-02-04 20:31:07 +00:00
refreshKey: String @isPrivate
2021-02-08 17:41:58 +00:00
userID: ID! @meta(gorm: "not null")
2021-02-02 20:34:10 +00:00
}
type MediaItem {
2021-02-04 10:16:13 +00:00
id: ID! @meta(gorm: "primaryKey;not null")
2021-02-02 20:34:10 +00:00
createdAt: Time
updatedAt: Time
exifDate: Time
2021-02-08 17:41:58 +00:00
latitude: Float @meta(gorm: "precision:5")
longitude: Float @meta(gorm: "precision:5")
2021-02-02 20:34:10 +00:00
isVideo: Boolean! @meta(gorm: "default:false;not null")
fileName: String! @meta(gorm: "not null")
origName: String! @meta(gorm: "not null")
2021-02-08 17:41:58 +00:00
tags: [Tag] @meta(gorm: "many2many:media_tags;foreignKey:ID,UserID;References:ID")
albums: [Album] @meta(gorm: "many2many:media_albums;foreignKey:ID,UserID;Refrences:ID")
2021-02-04 10:16:13 +00:00
userID: ID! @meta(gorm: "not null")
2021-02-02 20:34:10 +00:00
}
type Tag {
2021-02-08 17:41:58 +00:00
id: ID! @meta(gorm: "primaryKey;not null")
2021-02-02 20:34:10 +00:00
createdAt: Time
updatedAt: Time
2021-02-08 17:41:58 +00:00
name: String! @meta(gorm: "unique;not null")
userID: ID! @meta(gorm: "not null")
2021-02-02 20:34:10 +00:00
}
type Album {
2021-02-07 02:11:44 +00:00
id: ID! @meta(gorm: "primaryKey;not null")
2021-02-02 20:34:10 +00:00
createdAt: Time
updatedAt: Time
2021-02-07 02:11:44 +00:00
name: String! @meta(gorm: "unique;not null")
2021-02-08 17:41:58 +00:00
userID: ID! @meta(gorm: "not null")
2021-02-02 20:34:10 +00:00
}
# ------------------------------------------------------------
# ---------------------- Object Filters ----------------------
# ------------------------------------------------------------
input UserFilter {
id: IDFilter
createdAt: TimeFilter
updatedAt: TimeFilter
username: StringFilter
firstName: StringFilter
lastName: StringFilter
role: RoleFilter
authType: AuthTypeFilter
2021-02-08 17:41:58 +00:00
# and: UserFilter
# or: UserFilter
2021-02-02 20:34:10 +00:00
}
input MediaItemFilter {
id: IDFilter
createdAt: TimeFilter
updatedAt: TimeFilter
exifDate: TimeFilter
latitude: FloatFilter
longitude: FloatFilter
isVideo: BooleanFilter
origName: StringFilter
tags: TagFilter
albums: AlbumFilter
2021-02-08 17:41:58 +00:00
# and: MediaItemFilter
# or: MediaItemFilter
2021-02-02 20:34:10 +00:00
}
input DeviceFilter {
id: IDFilter
createdAt: TimeFilter
updatedAt: TimeFilter
name: StringFilter
type: DeviceTypeFilter
2021-02-08 17:41:58 +00:00
# and: MediaItemFilter
# or: MediaItemFilter
2021-02-02 20:34:10 +00:00
}
input TagFilter {
id: IDFilter
createdAt: TimeFilter
updatedAt: TimeFilter
name: StringFilter
2021-02-08 17:41:58 +00:00
# and: MediaItemFilter
# or: MediaItemFilter
2021-02-02 20:34:10 +00:00
}
input AlbumFilter {
id: IDFilter
createdAt: TimeFilter
updatedAt: TimeFilter
name: StringFilter
2021-02-08 17:41:58 +00:00
# and: MediaItemFilter
# or: MediaItemFilter
2021-02-02 20:34:10 +00:00
}
# ------------------------------------------------------------
# -------------------------- Inputs --------------------------
# ------------------------------------------------------------
input NewUser {
email: String!
username: String!
firstName: String
lastName: String
role: Role!
authType: AuthType!
password: String
}
input NewMediaItem {
file: Upload!
tags: [ID!]
albums: [ID!]
}
input NewTag {
name: String!
}
input NewAlbum {
name: String!
}
2021-02-09 00:42:20 +00:00
input Page {
size: Int
page: Int
}
input Order {
by: String
direction: OrderDirection
}
2021-02-02 20:34:10 +00:00
# ------------------------------------------------------------
# ------------------------ Responses -------------------------
# ------------------------------------------------------------
2021-02-09 00:42:20 +00:00
type PageResponse {
size: Int!
2021-02-02 20:34:10 +00:00
page: Int!
total: Int!
}
type MediaItemResponse {
data: [MediaItem]
2021-02-09 00:42:20 +00:00
page: PageResponse!
2021-02-02 20:34:10 +00:00
}
type UserResponse {
data: [User]
2021-02-09 00:42:20 +00:00
page: PageResponse!
2021-02-02 20:34:10 +00:00
}
type DeviceResponse {
data: [Device]
2021-02-09 00:42:20 +00:00
page: PageResponse!
2021-02-02 20:34:10 +00:00
}
type TagResponse {
data: [Tag]
2021-02-09 00:42:20 +00:00
page: PageResponse!
2021-02-02 20:34:10 +00:00
}
type AlbumResponse {
data: [Album]
2021-02-09 00:42:20 +00:00
page: PageResponse!
2021-02-02 20:34:10 +00:00
}
# ------------------------------------------------------------
# --------------------- Query & Mutations --------------------
# ------------------------------------------------------------
type Query {
2021-02-03 03:55:35 +00:00
# Authentication
login(
user: String!
password: String!
2021-02-04 10:16:13 +00:00
deviceID: ID
): AuthResponse!
2021-02-09 00:42:20 +00:00
logout: AuthResponse! @hasMinRole(role: User)
2021-02-03 03:55:35 +00:00
2021-02-02 20:34:10 +00:00
# Single Item
2021-02-07 02:11:44 +00:00
mediaItem(
id: ID!
2021-02-09 00:42:20 +00:00
): MediaItem! @hasMinRole(role: User)
2021-02-07 02:11:44 +00:00
device(
id: ID!
2021-02-09 00:42:20 +00:00
): Device! @hasMinRole(role: User)
2021-02-07 02:11:44 +00:00
album(
id: ID!
2021-02-09 00:42:20 +00:00
): Album! @hasMinRole(role: User)
2021-02-07 02:11:44 +00:00
user(
id: ID!
2021-02-09 00:42:20 +00:00
): User! @hasMinRole(role: Admin)
2021-02-07 02:11:44 +00:00
tag(
id: ID!
2021-02-09 00:42:20 +00:00
): Tag! @hasMinRole(role: User)
me: User! @hasMinRole(role: User)
2021-02-02 20:34:10 +00:00
# All
mediaItems(
filter: MediaItemFilter
2021-02-09 00:42:20 +00:00
page: Page
order: Order
): MediaItemResponse! @hasMinRole(role: User)
2021-02-02 20:34:10 +00:00
devices(
filter: DeviceFilter
2021-02-09 00:42:20 +00:00
page: Page
order: Order
): DeviceResponse! @hasMinRole(role: User)
2021-02-02 20:34:10 +00:00
albums(
filter: AlbumFilter
2021-02-09 00:42:20 +00:00
page: Page
order: Order
): AlbumResponse! @hasMinRole(role: User)
2021-02-02 20:34:10 +00:00
tags(
filter: TagFilter
2021-02-09 00:42:20 +00:00
page: Page
order: Order
): TagResponse! @hasMinRole(role: User)
2021-02-02 20:34:10 +00:00
users(
filter: UserFilter
2021-02-09 00:42:20 +00:00
page: Page
order: Order
): UserResponse! @hasMinRole(role: Admin)
2021-02-02 20:34:10 +00:00
}
type Mutation {
2021-02-03 03:55:35 +00:00
createMediaItem(input: NewMediaItem!): MediaItem! @hasMinRole(role: User)
createAlbum(input: NewAlbum!): Album! @hasMinRole(role: User)
createTag(input: NewTag!): Tag! @hasMinRole(role: User)
createUser(input: NewUser!): User! @hasMinRole(role: Admin)
2021-02-02 20:34:10 +00:00
}