MCPcopy Create free account
hub / github.com/dagger/dagger / InstallObject

Method InstallObject

dagql/dagql_test.go:3442–3470  ·  view source on GitHub ↗
(class dagql.ObjectType, _ ...*ast.Directive)

Source from the content-addressed store, hash-verified

3440}
3441
3442func (hook *testInstallHook) InstallObject(class dagql.ObjectType, _ ...*ast.Directive) {
3443 if strings.HasSuffix(class.TypeName(), "Other") {
3444 return
3445 }
3446
3447 // test extending a field
3448 class.Extend(
3449 dagql.FieldSpec{
3450 Name: "hello",
3451 Type: dagql.String(""),
3452 },
3453 func(ctx context.Context, self dagql.AnyResult, args map[string]dagql.Input) (dagql.AnyResult, error) {
3454 return dagql.NewResultForCurrentCall(ctx, dagql.String("hello world!"))
3455 },
3456 )
3457
3458 // test adding a new type
3459 classOther := renamedType{class, class.TypeName() + "Other"}
3460 hook.Server.InstallObject(classOther)
3461 hook.Server.Root().ObjectType().Extend(
3462 dagql.FieldSpec{
3463 Name: "other" + class.TypeName(),
3464 Type: classOther.Typed(),
3465 },
3466 func(ctx context.Context, self dagql.AnyResult, args map[string]dagql.Input) (dagql.AnyResult, error) {
3467 return dagql.NewResultForCurrentCall(ctx, &points.Point{X: 100, Y: 200})
3468 },
3469 )
3470}
3471
3472func TestInstallHooks(t *testing.T) {
3473 srv := newExternalDagqlServerForTest(t, Query{})

Callers

nothing calls this directly

Calls 8

StringTypeAlias · 0.92
NewResultForCurrentCallFunction · 0.92
TypeNameMethod · 0.65
ExtendMethod · 0.65
InstallObjectMethod · 0.65
ObjectTypeMethod · 0.65
TypedMethod · 0.65
RootMethod · 0.45

Tested by

no test coverage detected