Skip to main content

Custom Types

A Dagger module can have multiple object types defined. It's important to understand that they are only accessible through chaining, starting from a function in the main object.

Here is an example of a github Dagger module, with a function named DaggerOrganization that returns a custom Organization type, itself containing a collection of Account types:

package main

import "main/internal/dagger"

type Github struct{}

func (module *Github) DaggerOrganization() *Organization {
url := ""
return &Organization{
URL: url,
Repositories: []*dagger.GitRepository{dag.Git(url + "/dagger")},
Members: []*Account{
{"jane", ""},
{"john", ""},

type Organization struct {
URL string
Repositories []*dagger.GitRepository
Members []*Account

type Account struct {
Username string
Email string

func (account *Account) URL() string {
return "" + account.Username

When the Dagger Engine extends the Dagger API schema with these types, it prefixes their names with the name of the main object:

  • Github
  • GithubAccount
  • GithubOrganization

This is to prevent possible naming conflicts when loading multiple modules, which is reflected in code generation (for example, when using this module in another one as a dependency).

Here's an example of calling a Dagger Function from this module to get all member URLs:

dagger call dagger-organization members url

The result will be: