-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgraphql.go
More file actions
62 lines (50 loc) · 1.15 KB
/
graphql.go
File metadata and controls
62 lines (50 loc) · 1.15 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package utils
import (
"strconv"
graphql "github.com/graph-gophers/graphql-go"
)
// Int64ToGraphQLID :nodoc:
func Int64ToGraphQLID(i int64) graphql.ID {
return graphql.ID(Int64ToString(i))
}
// GraphQLIDToString :nodoc:
func GraphQLIDToString(id graphql.ID) string {
return string(id)
}
// GraphQLIDPointerToString :nodoc:
func GraphQLIDPointerToString(id *graphql.ID) string {
if id == nil {
return ""
}
return string(*id)
}
// GraphQLIDToInt64 :nodoc:
func GraphQLIDToInt64(id graphql.ID) int64 {
return StringToInt64(string(id))
}
// GraphQLIDPointerToInt64 :nodoc:
func GraphQLIDPointerToInt64(id *graphql.ID) int64 {
if id == nil {
return int64(0)
}
return StringToInt64(string(*id))
}
// GraphQLIDToInt32 Deprecated. Do not use.
func GraphQLIDToInt32(id graphql.ID) int32 {
newID, err := strconv.Atoi(string(id))
if err != nil {
return int32(0)
}
return int32(newID) //nolint:gosec
}
// GraphQLIDPointerToInt32 Deprecated. Do not use.
func GraphQLIDPointerToInt32(id *graphql.ID) int32 {
if id == nil {
return int32(0)
}
newID, err := strconv.Atoi(string(*id))
if err != nil {
return int32(0)
}
return int32(newID) //nolint:gosec
}