-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphoto.go
42 lines (35 loc) · 970 Bytes
/
photo.go
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
package main
import "github.com/graphql-go/graphql"
var _ PhotoService = (*photoService)(nil)
type PhotoService interface {
Photos(p graphql.ResolveParams) (interface{}, error)
Photo(p graphql.ResolveParams) (interface{}, error)
}
var photoType = graphql.NewObject(graphql.ObjectConfig{
Name: "Photo",
Fields: graphql.Fields{
"albumId": &graphql.Field{
Type: graphql.Int,
},
"id": &graphql.Field{
Type: graphql.Int,
},
"title": &graphql.Field{
Type: graphql.String,
},
"url": &graphql.Field{
Type: graphql.String,
},
"thumbnailUrl": &graphql.Field{
Type: graphql.String,
},
}},
)
type photoService struct{ *Resolver }
func (p *photoService) Photos(params graphql.ResolveParams) (interface{}, error) {
return p.Client.Photo.List(params.Context)
}
func (p *photoService) Photo(params graphql.ResolveParams) (interface{}, error) {
input := uint64(params.Args["id"].(int))
return p.Client.Photo.Get(params.Context, input)
}