Skip to main content

Dagger NodeJS SDK

api/client.gen.TypeDef

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

Hierarchy

  • BaseClient

    TypeDef

Constructors

constructor

new TypeDef(parent?, _id?, _kind?, _optional?): TypeDef

Constructor is used for internal usage only, do not create object from it.

Parameters

NameType
parent?Object
parent.ctxContext
parent.queryTree?QueryTree[]
_id?TypeDefID
_kind?TypeDefKind
_optional?boolean

Returns

TypeDef

Overrides

BaseClient.constructor

Properties

_id

Private Optional Readonly _id: TypeDefID = undefined


_kind

Private Optional Readonly _kind: TypeDefKind = undefined


_optional

Private Optional Readonly _optional: boolean = undefined

Methods

asInput

asInput(): InputTypeDef

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

Returns

InputTypeDef


asInterface

asInterface(): InterfaceTypeDef

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

Returns

InterfaceTypeDef


asList

asList(): ListTypeDef

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

Returns

ListTypeDef


asObject

asObject(): ObjectTypeDef

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

Returns

ObjectTypeDef


id

id(): Promise<TypeDefID>

A unique identifier for this TypeDef.

Returns

Promise<TypeDefID>


kind

kind(): Promise<TypeDefKind>

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

Returns

Promise<TypeDefKind>


optional

optional(): Promise<boolean>

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

Returns

Promise<boolean>


with

with(arg): TypeDef

Call the provided function with current TypeDef.

This is useful for reusability and readability by not breaking the calling chain.

Parameters

NameType
arg(param: TypeDef) => TypeDef

Returns

TypeDef


withConstructor

withConstructor(function_): TypeDef

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

Parameters

NameType
function_Function_

Returns

TypeDef


withField

withField(name, typeDef, opts?): TypeDef

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

Parameters

NameTypeDescription
namestringThe name of the field in the object
typeDefTypeDefThe type of the field
opts?TypeDefWithFieldOpts-

Returns

TypeDef


withFunction

withFunction(function_): TypeDef

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

Parameters

NameType
function_Function_

Returns

TypeDef


withInterface

withInterface(name, opts?): TypeDef

Returns a TypeDef of kind Interface with the provided name.

Parameters

NameType
namestring
opts?TypeDefWithInterfaceOpts

Returns

TypeDef


withKind

withKind(kind): TypeDef

Sets the kind of the type.

Parameters

NameType
kindTypeDefKind

Returns

TypeDef


withListOf

withListOf(elementType): TypeDef

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

Parameters

NameType
elementTypeTypeDef

Returns

TypeDef


withObject

withObject(name, opts?): TypeDef

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.

Parameters

NameType
namestring
opts?TypeDefWithObjectOpts

Returns

TypeDef


withOptional

withOptional(optional): TypeDef

Sets whether this type can be set to null.

Parameters

NameType
optionalboolean

Returns

TypeDef