#I don't understand graphql

1 messages · Page 1 of 1 (latest)

uncut zodiac
#

Supposing we have a zenith module:

package main

import "context"

const (
    base           = "cgr.dev/chainguard/wolfi-base"
    defaultVersion = "1.21.3"
)

type Golang struct {
    Ctr     *Container
    Version string
}

func (m *Golang) WithContainer(container *Container) *Golang {
    m.Ctr = container

    return m
}

func (m *Golang) WithVersion(version string) *Golang {
    m.Version = version

    return m
}

func (m *Golang) Container(ctx context.Context) (*Container, error) {
    version := m.Version

    if version == "" {
        version = defaultVersion
    }

    ctr := dag.Container().From(base)

    ctr = ctr.WithExec([]string{"apk", "add", "go"})

    return ctr, nil
}

How can i structure graphql request?

{
    golang {
        withContainer(container: ?){
            withVersion(version: "1.21.3") {
                container {
                    withExec(args: ["go", "version"]) {
                        stdout
                    }
                }
            }
        }
    }
}
misty gale
#

With GraphQL you'll have to get the { container { id } } first and use it in withContainer(container: $container_id).

#

Just to confirm, you don't want to use the CLI in this case?

uncut zodiac
#

no, i need to test my module and i had some issue to run module in a go test, for that reason i'am trying to run module through the cli

misty gale
#

I'm confused, you said you're trying to run the module through the CLI? You mean dagger query? Do you know about dagger call?

uncut zodiac
#

yes, i mean dagger query: cat example.graphql | dagger query

misty gale
#

Yes, but why not dagger call?

uncut zodiac
#

Thank you for the suggestion