This commit is contained in:
@@ -2,9 +2,12 @@ package resolvers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.aiterp.net/rpdata/api/graph2/graphcore"
|
||||
"git.aiterp.net/rpdata/api/models"
|
||||
)
|
||||
|
||||
// Queries
|
||||
|
||||
func (r *queryResolver) File(ctx context.Context, id string) (*models.File, error) {
|
||||
return r.s.Files.Find(ctx, id)
|
||||
}
|
||||
@@ -20,3 +23,9 @@ func (r *queryResolver) Files(ctx context.Context, filter *models.FileFilter) ([
|
||||
|
||||
return r.s.Files.List(ctx, *filter)
|
||||
}
|
||||
|
||||
// Mutations
|
||||
|
||||
func (r *mutationResolver) UploadFile(ctx context.Context, input *graphcore.FileUploadInput) (*models.File, error) {
|
||||
return r.s.Files.Upload(ctx, input.File.File, input.Name, input.Public, input.File.Size)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
type queryResolver struct{ s *services.Bundle }
|
||||
type mutationResolver struct{ s *services.Bundle }
|
||||
|
||||
type subscriptionResolver struct{ s *services.Bundle }
|
||||
|
||||
// QueryResolver has all the queries
|
||||
|
||||
@@ -107,7 +107,7 @@ type Mutation {
|
||||
"Edit a comment in a chapter."
|
||||
editComment(input: CommentEditInput!): Comment!
|
||||
|
||||
"Remove a comemnt in a chapter."
|
||||
"Remove a comment in a chapter."
|
||||
removeComment(input: CommentRemoveInput!): Comment!
|
||||
|
||||
|
||||
@@ -164,6 +164,10 @@ type Mutation {
|
||||
|
||||
# Edit a channel
|
||||
editChannel(input: ChannelEditInput!): Channel!
|
||||
|
||||
|
||||
"Upload a file"
|
||||
uploadFile(input: FileUploadInput): File!
|
||||
}
|
||||
|
||||
type Subscription {
|
||||
@@ -176,3 +180,5 @@ type Subscription {
|
||||
# A Time represents a RFC3339 encoded date with up to millisecond precision.
|
||||
scalar Time
|
||||
|
||||
"""A GraphQL file upload."""
|
||||
scalar Upload
|
||||
@@ -64,6 +64,8 @@ enum ChangeModel {
|
||||
Story
|
||||
Tag
|
||||
Chapter
|
||||
Comment
|
||||
File
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
@@ -38,9 +38,21 @@ input FilesFilter {
|
||||
mimeTypes: [String!]
|
||||
}
|
||||
|
||||
# Input for uploadFile mutation
|
||||
input FileUploadInput {
|
||||
"The file name"
|
||||
name: String!
|
||||
|
||||
# Whether the file should be public
|
||||
public: Boolean!
|
||||
|
||||
# The actual file upload
|
||||
file: Upload!
|
||||
}
|
||||
|
||||
# Input for editFile mutation
|
||||
input EditFileInput {
|
||||
# The file's unique ID
|
||||
# The file's unique ID
|
||||
id: String!
|
||||
|
||||
# Whether the file is publicly listable. Someone with knowledge of the ID
|
||||
|
||||
Reference in New Issue
Block a user