a schema that can resolve time.Time
values.
Example: we can use the
gq.Date
schema to resolvetime.Time
or*time.Time
values.
type User struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
}
schema := gq.Object[User]{
Name: "User",
Description: "...",
Fields: gq.Fields{
"id": gq.Field{
Type: gq.String{},
},
"name": gq.Field{
Type: gq.String{},
},
"created_at": gq.Field{
Type: gq.Date{},
},
},
}
now := time.Now()
res := schema.Do(&gq.DoParams{
Query: "{id,name,created_at}",
Value: User{
ID: "1",
Name: "test",
CreatedAt: &now,
},
})
if res.Error != nil {
panic(res.Error)
}