-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.go
117 lines (90 loc) · 4.2 KB
/
configuration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package enthasura
// func enhanceHasuraTable(source *metadata.Source, table *metadata.TableDefinition) {
// for i, iTable := range source.Tables {
// qName, _ := iTable.Table.(metadata.QualifiedTableName)
// if qName.Schema != qName.Schema || qName.Name != qName.Name {
// continue
// }
// if source.Tables[i].Configuration == nil {
// source.Tables[i].Configuration = &metadata.TableConfiguration{}
// }
// if source.Tables[i].Configuration.CustomName == "" {
// source.Tables[i].Configuration.CustomName = table.Configuration.CustomName
// }
// if source.Tables[i].Configuration.CustomRootFields == nil {
// source.Tables[i].Configuration.CustomRootFields = &metadata.CustomRootFields{}
// }
// if source.Tables[i].Configuration.CustomRootFields.Insert == "" {
// source.Tables[i].Configuration.CustomRootFields.Insert = table.Configuration.CustomRootFields.Insert
// }
// if source.Tables[i].Configuration.CustomRootFields.InsertOne == "" {
// source.Tables[i].Configuration.CustomRootFields.InsertOne = table.Configuration.CustomRootFields.InsertOne
// }
// if source.Tables[i].Configuration.CustomRootFields.Update == "" {
// source.Tables[i].Configuration.CustomRootFields.Update = table.Configuration.CustomRootFields.Update
// }
// if source.Tables[i].Configuration.CustomRootFields.UpdateByPk == "" {
// source.Tables[i].Configuration.CustomRootFields.UpdateByPk = table.Configuration.CustomRootFields.UpdateByPk
// }
// if source.Tables[i].Configuration.CustomRootFields.Select == "" {
// source.Tables[i].Configuration.CustomRootFields.Select = table.Configuration.CustomRootFields.Select
// }
// if source.Tables[i].Configuration.CustomRootFields.Delete == "" {
// source.Tables[i].Configuration.CustomRootFields.Delete = table.Configuration.CustomRootFields.Delete
// }
// if source.Tables[i].Configuration.CustomRootFields.DeleteByPk == "" {
// source.Tables[i].Configuration.CustomRootFields.DeleteByPk = table.Configuration.CustomRootFields.DeleteByPk
// }
// if source.Tables[i].Configuration.CustomRootFields.SelectAggregate == "" {
// source.Tables[i].Configuration.CustomRootFields.SelectAggregate = table.Configuration.CustomRootFields.SelectAggregate
// }
// if source.Tables[i].Configuration.CustomRootFields.SelectByPk == "" {
// source.Tables[i].Configuration.CustomRootFields.SelectByPk = table.Configuration.CustomRootFields.SelectByPk
// }
// source.Tables[i].Configuration.CustomColumnNames = table.Configuration.CustomColumnNames
// source.Tables[i].ObjectRelationships = table.ObjectRelationships
// source.Tables[i].ArrayRelationships = table.ArrayRelationships
// }
// }
// func enhancedHasuraConfigurationAndRelationships(initial *HasuraMetadata, schema *gen.Graph, sourceName, schemaName string, overrideTables bool) error {
// initial.ResourceVersion += 1
// tables, err := obtainHasuraTablesFromEntSchema(schema, schemaName)
// if err != nil {
// return err
// }
// for _, source := range initial.Metadata.Sources {
// if source.Name == sourceName {
// if overrideTables {
// source.Tables = tables
// break
// }
// for _, table := range tables {
// enhanceHasuraTable(source, table)
// }
// }
// }
// return nil
// }
// func GenerateHasuraConfigurationAndRelationships(schemaRoute string, outputFile, inputFile, source, schemaName string, overrideTables bool, defaultRole string) error {
// graph, err := entc.LoadGraph(schemaRoute, &gen.Config{})
// if err != nil {
// return errors.WithStack(err)
// }
// if inputFile == "" { // If input file is not specified, use the default
// return generateRawMetadata(graph, schemaName, outputFile)
// }
// initialMetadata, err := parseHasuraMetadata(inputFile)
// if err != nil {
// return errors.WithStack(err)
// }
// if defaultRole != "" {
// err := enhancedHasuraPermissions(initialMetadata, graph, source, defaultRole, schemaName)
// if err != nil {
// return errors.WithStack(err)
// }
// }
// if err := enhancedHasuraConfigurationAndRelationships(initialMetadata, graph, source, schemaName, overrideTables); err != nil {
// return errors.WithStack(err)
// }
// return generateFile(*initialMetadata, outputFile)
// }