Skip to content

Commit

Permalink
WIP/SQUASH - Fix test flackiness
Browse files Browse the repository at this point in the history
Tests were randomly failing as golang was randomizing the maps
  • Loading branch information
AndrewSisley committed Nov 16, 2021
1 parent 5949c8b commit fb55cd3
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions query/graphql/schema/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,13 @@ func (g *Generator) expandInputArgument(obj *gql.Object) error {
if _, ok := parser.ReservedFields[f]; ok && f != parser.GroupFieldName {
continue
}
typeKey := obj.Name() + f
switch t := def.Type.(type) {
case *gql.Object:
if _, complete := g.expandedTypes[obj.Name()]; complete {
if _, complete := g.expandedTypes[typeKey]; complete {
continue
} else {
g.expandedTypes[obj.Name()] = true
g.expandedTypes[typeKey] = true
}
// make sure all the sub fields are expanded first
if err := g.expandInputArgument(t); err != nil {
Expand All @@ -172,10 +173,10 @@ func (g *Generator) expandInputArgument(obj *gql.Object) error {
break
case *gql.List: // new field object with aguments (list)
listType := t.OfType
if _, complete := g.expandedTypes[obj.Name()]; complete {
if _, complete := g.expandedTypes[typeKey]; complete {
continue
} else {
g.expandedTypes[obj.Name()] = true
g.expandedTypes[typeKey] = true
}

if listObjType, ok := listType.(*gql.Object); ok {
Expand Down Expand Up @@ -496,8 +497,14 @@ func (g *Generator) genTypeFieldsEnum(obj *gql.Object) *gql.Enum {
Values: gql.EnumValueConfigMap{},
}

for i, field := range obj.Fields() {
enumFieldsCfg.Values[field.Name] = &gql.EnumValueConfig{Value: i}
for f, field := range obj.Fields() {
if _, ok := parser.ReservedFields[f]; ok && f != "_key" {
continue
}
if !gql.IsLeafType(field.Type) {
continue
}
enumFieldsCfg.Values[field.Name] = &gql.EnumValueConfig{Value: f}
}

return gql.NewEnum(enumFieldsCfg)
Expand Down

0 comments on commit fb55cd3

Please sign in to comment.