MCPcopy Index your code
hub / github.com/dosco/graphjin / TestBuildChildGraphQLQuery

Function TestBuildChildGraphQLQuery

core/multidb_test.go:608–715  ·  view source on GitHub ↗

TestBuildChildGraphQLQuery tests construction of GraphQL sub-queries for cross-database child table fetching.

(t *testing.T)

Source from the content-addressed store, hash-verified

606// TestBuildChildGraphQLQuery tests construction of GraphQL sub-queries
607// for cross-database child table fetching.
608func TestBuildChildGraphQLQuery(t *testing.T) {
609 tests := []struct {
610 name string
611 sel *qcode.Select
612 selects []qcode.Select
613 fkCol sdata.DBColumn
614 parentID []byte
615 want string
616 }{
617 {
618 name: "simple numeric parent ID",
619 sel: &qcode.Select{
620 Table: "orders",
621 Fields: []qcode.Field{
622 {FieldName: "id"},
623 {FieldName: "total"},
624 },
625 },
626 selects: []qcode.Select{},
627 fkCol: sdata.DBColumn{Name: "user_id", Type: "bigint"},
628 parentID: []byte("42"),
629 want: "query { orders(where: {user_id: {eq: 42}}) { id total } }",
630 },
631 {
632 name: "string parent ID (quoted)",
633 sel: &qcode.Select{
634 Table: "orders",
635 Fields: []qcode.Field{
636 {FieldName: "id"},
637 {FieldName: "total"},
638 },
639 },
640 selects: []qcode.Select{},
641 fkCol: sdata.DBColumn{Name: "user_id", Type: "bigint"},
642 parentID: []byte(`"abc"`),
643 want: `query { orders(where: {user_id: {eq: "abc"}}) { id total } }`,
644 },
645 {
646 name: "with nested children",
647 sel: &qcode.Select{
648 Field: qcode.Field{ID: 0},
649 Table: "orders",
650 Fields: []qcode.Field{
651 {FieldName: "id"},
652 {FieldName: "total"},
653 },
654 Children: []int32{1},
655 },
656 selects: []qcode.Select{
657 {}, // placeholder for index 0 (the parent sel itself)
658 {
659 Field: qcode.Field{
660 FieldName: "items",
661 SkipRender: qcode.SkipTypeNone,
662 },
663 Table: "items",
664 Fields: []qcode.Field{
665 {FieldName: "name"},

Callers

nothing calls this directly

Calls 1

buildChildGraphQLQueryFunction · 0.85

Tested by

no test coverage detected