-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolver_note.go
More file actions
43 lines (33 loc) · 852 Bytes
/
resolver_note.go
File metadata and controls
43 lines (33 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"context"
"time"
graphql "github.com/graph-gophers/graphql-go"
)
type Note struct {
UserID graphql.ID
NoteID graphql.ID
CreatedAt time.Time
UpdatedAt time.Time
Data string
}
type NoteResolver struct{ note *Note }
func (r *NoteResolver) UserID() graphql.ID {
return r.note.UserID
}
func (r *NoteResolver) NoteID() graphql.ID {
return r.note.NoteID
}
func (r *NoteResolver) CreatedAt() string {
return r.note.CreatedAt.UTC().Format(PostgresTimestamptzFormat)
}
func (r *NoteResolver) UpdatedAt() string {
return r.note.UpdatedAt.UTC().Format(PostgresTimestamptzFormat)
}
func (r *NoteResolver) Data() string {
return r.note.Data
}
func (r *NoteResolver) User(ctx context.Context) (*UserResolver, error) {
userArgs := struct{ UserID graphql.ID }{r.note.UserID}
return RootRx.User(ctx, userArgs)
}