/
timestamp.go
executable file
·92 lines (81 loc) · 3.01 KB
/
timestamp.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This file was generated by github.com/EGT-Ukraine/go2gql. DO NOT EDIT IT
package well_known
import (
context "context"
scalars "github.com/EGT-Ukraine/go2gql/api/scalars"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
graphql "github.com/graphql-go/graphql"
errors "github.com/pkg/errors"
)
// Enums
// Input object
var TimestampInput = graphql.NewInputObject(graphql.InputObjectConfig{
Name: "TimestampInput",
Fields: graphql.InputObjectConfigFieldMap{},
})
func init() {
TimestampInput.AddFieldConfig("seconds", &graphql.InputObjectFieldConfig{Type: scalars.GraphQLInt64Scalar, Description: "Represents seconds of UTC time since Unix epoch\n 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n 9999-12-31T23:59:59Z inclusive."})
TimestampInput.AddFieldConfig("nanos", &graphql.InputObjectFieldConfig{Type: scalars.GraphQLInt32Scalar, Description: "Non-negative fractions of a second at nanosecond resolution. Negative\n second values with fractions must still have non-negative nanos values\n that count forward in time. Must be from 0 to 999,999,999\n inclusive."})
}
// Input objects resolvers
func ResolveTimestampInput(ctx context.Context, i interface{}) (_ *timestamp.Timestamp, rerr error) {
if i == nil {
return nil, nil
}
args, _ := i.(map[string]interface{})
_ = args
var result = new(timestamp.Timestamp)
if args["seconds"] != nil {
result.Seconds = args["seconds"].(int64)
}
if args["nanos"] != nil {
result.Nanos = args["nanos"].(int32)
}
return result, nil
}
// Output objects
var Timestamp = graphql.NewObject(graphql.ObjectConfig{
Name: "Timestamp",
Fields: graphql.Fields{},
})
func init() {
Timestamp.AddFieldConfig("seconds", &graphql.Field{
Name: "seconds",
Description: "Represents seconds of UTC time since Unix epoch\n 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n 9999-12-31T23:59:59Z inclusive.",
Type: scalars.GraphQLInt64Scalar,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
switch src := p.Source.(type) {
case *timestamp.Timestamp:
if src == nil {
return nil, nil
}
s := *src
return s.GetSeconds(), nil
case timestamp.Timestamp:
return src.GetSeconds(), nil
}
return nil, errors.New("source of unknown type")
},
})
Timestamp.AddFieldConfig("nanos", &graphql.Field{
Name: "nanos",
Description: "Non-negative fractions of a second at nanosecond resolution. Negative\n second values with fractions must still have non-negative nanos values\n that count forward in time. Must be from 0 to 999,999,999\n inclusive.",
Type: scalars.GraphQLInt32Scalar,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
switch src := p.Source.(type) {
case *timestamp.Timestamp:
if src == nil {
return nil, nil
}
s := *src
return s.GetNanos(), nil
case timestamp.Timestamp:
return src.GetNanos(), nil
}
return nil, errors.New("source of unknown type")
},
})
}
// Maps input objects
// Maps input objects resolvers
// Maps output objects