/
void.go
52 lines (39 loc) · 914 Bytes
/
void.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package core
import (
"fmt"
"github.com/vektah/gqlparser/v2/ast"
"github.com/dagger/dagger/dagql"
"github.com/dagger/dagger/dagql/call"
)
type Void struct{}
var _ dagql.Typed = Void{}
func (p Void) TypeName() string {
return "Void"
}
func (p Void) TypeDescription() string {
return dagql.FormatDescription(
`The absence of a value.`,
`A Null Void is used as a placeholder for resolvers that do not return anything.`)
}
func (p Void) Type() *ast.Type {
return &ast.Type{
NamedType: p.TypeName(),
NonNull: true,
}
}
var _ dagql.Input = Void{}
func (p Void) Decoder() dagql.InputDecoder {
return p
}
func (p Void) ToLiteral() call.Literal {
return call.NewLiteralNull()
}
var _ dagql.ScalarType = Void{}
func (Void) DecodeInput(val any) (dagql.Input, error) {
switch val.(type) {
case nil:
return nil, nil
default:
return nil, fmt.Errorf("cannot convert %T to Void", val)
}
}