Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Json and non standard Scalar types #517

Open
lantos1618 opened this issue Jul 7, 2022 · 0 comments
Open

Json and non standard Scalar types #517

lantos1618 opened this issue Jul 7, 2022 · 0 comments

Comments

@lantos1618
Copy link

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
	})
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant