(t *testing.T)
| 807 | } |
| 808 | |
| 809 | func 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. |
| 861 | func TestWriteSelectFields(t *testing.T) { |
nothing calls this directly
no test coverage detected