(class dagql.ObjectType, _ ...*ast.Directive)
| 3440 | } |
| 3441 | |
| 3442 | func (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 | |
| 3472 | func TestInstallHooks(t *testing.T) { |
| 3473 | srv := newExternalDagqlServerForTest(t, Query{}) |
nothing calls this directly
no test coverage detected