# `Dagger.TypeDef`
[🔗](https://github.com/dagger/dagger/blob/v0.20.5/sdk/elixir/lib/dagger/gen/type_def.ex#L2)

A definition of a parameter or return type in a Module.

# `t`

```elixir
@type t() :: %Dagger.TypeDef{client: term(), query_builder: term()}
```

# `as_enum`

```elixir
@spec as_enum(t()) :: Dagger.EnumTypeDef.t() | nil
```

If kind is ENUM, the enum-specific type definition. If kind is not ENUM, this will be null.

# `as_input`

```elixir
@spec as_input(t()) :: Dagger.InputTypeDef.t() | nil
```

If kind is INPUT, the input-specific type definition. If kind is not INPUT, this will be null.

# `as_interface`

```elixir
@spec as_interface(t()) :: Dagger.InterfaceTypeDef.t() | nil
```

If kind is INTERFACE, the interface-specific type definition. If kind is not INTERFACE, this will be null.

# `as_list`

```elixir
@spec as_list(t()) :: Dagger.ListTypeDef.t() | nil
```

If kind is LIST, the list-specific type definition. If kind is not LIST, this will be null.

# `as_object`

```elixir
@spec as_object(t()) :: Dagger.ObjectTypeDef.t() | nil
```

If kind is OBJECT, the object-specific type definition. If kind is not OBJECT, this will be null.

# `as_scalar`

```elixir
@spec as_scalar(t()) :: Dagger.ScalarTypeDef.t() | nil
```

If kind is SCALAR, the scalar-specific type definition. If kind is not SCALAR, this will be null.

# `id`

```elixir
@spec id(t()) :: {:ok, Dagger.TypeDefID.t()} | {:error, term()}
```

A unique identifier for this TypeDef.

# `kind`

```elixir
@spec kind(t()) :: {:ok, Dagger.TypeDefKind.t()} | {:error, term()}
```

The kind of type this is (e.g. primitive, list, object).

# `optional`

```elixir
@spec optional(t()) :: {:ok, boolean()} | {:error, term()}
```

Whether this type can be set to null. Defaults to false.

# `with_constructor`

```elixir
@spec with_constructor(t(), Dagger.Function.t()) :: t()
```

Adds a function for constructing a new instance of an Object TypeDef, failing if the type is not an object.

# `with_enum`

```elixir
@spec with_enum(t(), String.t(),
  description: String.t() | nil,
  source_map: Dagger.SourceMapID.t() | nil
) :: t()
```

Returns a TypeDef of kind Enum with the provided name.

Note that an enum's values may be omitted if the intent is only to refer to an enum. This is how functions are able to return their own, or any other circular reference.

# `with_enum_member`

```elixir
@spec with_enum_member(t(), String.t(),
  value: String.t() | nil,
  description: String.t() | nil,
  source_map: Dagger.SourceMapID.t() | nil,
  deprecated: String.t() | nil
) :: t()
```

Adds a static value for an Enum TypeDef, failing if the type is not an enum.

# `with_enum_value`

> This function is deprecated. Use `with_enum_member` instead
.

```elixir
@spec with_enum_value(t(), String.t(),
  description: String.t() | nil,
  source_map: Dagger.SourceMapID.t() | nil,
  deprecated: String.t() | nil
) :: t()
```

Adds a static value for an Enum TypeDef, failing if the type is not an enum.

# `with_field`

```elixir
@spec with_field(t(), String.t(), t(),
  description: String.t() | nil,
  source_map: Dagger.SourceMapID.t() | nil,
  deprecated: String.t() | nil
) :: t()
```

Adds a static field for an Object TypeDef, failing if the type is not an object.

# `with_function`

```elixir
@spec with_function(t(), Dagger.Function.t()) :: t()
```

Adds a function for an Object or Interface TypeDef, failing if the type is not one of those kinds.

# `with_interface`

```elixir
@spec with_interface(t(), String.t(),
  description: String.t() | nil,
  source_map: Dagger.SourceMapID.t() | nil
) :: t()
```

Returns a TypeDef of kind Interface with the provided name.

# `with_kind`

```elixir
@spec with_kind(t(), Dagger.TypeDefKind.t()) :: t()
```

Sets the kind of the type.

# `with_list_of`

```elixir
@spec with_list_of(t(), t()) :: t()
```

Returns a TypeDef of kind List with the provided type for its elements.

# `with_object`

```elixir
@spec with_object(t(), String.t(),
  description: String.t() | nil,
  source_map: Dagger.SourceMapID.t() | nil,
  deprecated: String.t() | nil
) :: t()
```

Returns a TypeDef of kind Object with the provided name.

Note that an object's fields and functions may be omitted if the intent is only to refer to an object. This is how functions are able to return their own object, or any other circular reference.

# `with_optional`

```elixir
@spec with_optional(t(), boolean()) :: t()
```

Sets whether this type can be set to null.

# `with_scalar`

```elixir
@spec with_scalar(t(), String.t(), [{:description, String.t() | nil}]) :: t()
```

Returns a TypeDef of kind Scalar with the provided name.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
