thunder
thunder copied to clipboard
Json and non standard Scalar types
Hi how can you specify tables/maps?
panic: bad method dockerContainers on type schemabuilder.query: bad field labels on type types.Container: bad type map[string]string: should be a scalar, slice, or struct type
I have tried graphql:",json"
but throws null pointer exception.
type Container struct {
ID string `json:"Id"`
Names []string
Image string
ImageID string
Command string
Created int64
Ports []Port
SizeRw int64 `json:",omitempty"`
SizeRootFs int64 `json:",omitempty"`
Labels map[string]string
State string
Status string
HostConfig struct {
NetworkMode string `json:",omitempty"`
}
NetworkSettings *SummaryNetworkSettings
Mounts []MountPoint
}
func (s *server) registerGetDockerContainers(schema *schemabuilder.Schema) {
obj := schema.Query()
obj.FieldFunc("dockerContainers", func() []types.Container {
ctx := context.Background()
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
panic(err)
}
containers, err := cli.ContainerList(ctx, types.ContainerListOptions{})
if err != nil {
panic(err)
}
return containers
})
}