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

Function TestBuildChildGraphQLQueryNestedDatabaseJoin

core/multidb_test.go:809–858  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

807}
808
809func TestBuildChildGraphQLQueryNestedDatabaseJoin(t *testing.T) {
810 sel := &qcode.Select{
811 Field: qcode.Field{
812 ID: 0,
813 FieldName: "orders",
814 SkipRender: qcode.SkipTypeDatabaseJoin,
815 },
816 Table: "orders",
817 Fields: []qcode.Field{
818 {FieldName: "id"},
819 },
820 Children: []int32{1, 2},
821 }
822 selects := []qcode.Select{
823 *sel,
824 {
825 Field: qcode.Field{
826 FieldName: "customer",
827 SkipRender: qcode.SkipTypeDatabaseJoin,
828 },
829 Table: "customer",
830 Fields: []qcode.Field{
831 {FieldName: "id"},
832 {FieldName: "name"},
833 },
834 },
835 {
836 Field: qcode.Field{
837 FieldName: "items",
838 SkipRender: qcode.SkipTypeNone,
839 },
840 Table: "items",
841 Fields: []qcode.Field{
842 {FieldName: "sku"},
843 {FieldName: "qty"},
844 },
845 },
846 }
847
848 got := string(buildChildGraphQLQuery(
849 sel,
850 selects,
851 sdata.DBColumn{Name: "account_id", Type: "varchar"},
852 []byte("acct-123"),
853 ))
854 want := `query { orders(where: {account_id: {eq: "acct-123"}}) { id customer { id name } items { sku qty } } }`
855 if got != want {
856 t.Errorf("buildChildGraphQLQuery() =\n %q\nwant:\n %q", got, want)
857 }
858}
859
860// TestWriteSelectFields tests field list generation for cross-database queries.
861func TestWriteSelectFields(t *testing.T) {

Callers

nothing calls this directly

Calls 1

buildChildGraphQLQueryFunction · 0.85

Tested by

no test coverage detected