Skip to content

Commit a7fa5fb

Browse files
committed
cleanup
On-behalf-of: @SAP [email protected] Signed-off-by: Artem Shcherbatiuk <[email protected]>
1 parent 1352210 commit a7fa5fb

File tree

2 files changed

+9
-63
lines changed

2 files changed

+9
-63
lines changed

gateway/resolver/relationships.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,3 @@ func (r *RelationshipResolver) fetchReferencedResource(ctx context.Context, ref
414414
}
415415

416416
// getOriginalGroupName converts sanitized group name back to original
417-
func (r *RelationshipResolver) getOriginalGroupName(groupName string) string {
418-
if originalName, ok := r.groupNames[groupName]; ok {
419-
return originalName
420-
}
421-
return groupName
422-
}

gateway/schema/schema.go

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -405,24 +405,16 @@ func (g *Gateway) generateGraphQLFields(resourceScheme *spec.Schema, typePrefix
405405
relationFieldName := strings.ToLower(string(targetKind[0])) + targetKind[1:] + "Relation"
406406

407407
relationFieldType := g.createEnhancedRefType(targetKind)
408-
if relationFieldType != nil {
409-
fields[relationFieldName] = &graphql.Field{
410-
Type: relationFieldType,
411-
Resolve: relationshipResolver.CreateSingleRelationResolver(*currentGVK, fieldName),
412-
}
413-
g.log.Info().
414-
Str("typePrefix", typePrefix).
415-
Str("fieldName", fieldName).
416-
Str("targetKind", targetKind).
417-
Str("relationFieldName", relationFieldName).
418-
Msg("Added individual relation field")
419-
} else {
420-
g.log.Info().
421-
Str("typePrefix", typePrefix).
422-
Str("fieldName", fieldName).
423-
Str("targetKind", targetKind).
424-
Msg("Failed to create relation field type")
408+
fields[relationFieldName] = &graphql.Field{
409+
Type: relationFieldType,
410+
Resolve: relationshipResolver.CreateSingleRelationResolver(*currentGVK, fieldName),
425411
}
412+
g.log.Info().
413+
Str("typePrefix", typePrefix).
414+
Str("fieldName", fieldName).
415+
Str("targetKind", targetKind).
416+
Str("relationFieldName", relationFieldName).
417+
Msg("Added individual relation field")
426418
}
427419
} else {
428420
g.log.Info().
@@ -699,46 +691,6 @@ func (g *Gateway) extractTargetKind(fieldName string) string {
699691
return resolver.ExtractTargetKind(fieldName)
700692
}
701693

702-
// getOrCreateTargetResourceType attempts to get or create the GraphQL type for the target resource
703-
func (g *Gateway) getOrCreateTargetResourceType(targetKind string, sourceGVK *schema.GroupVersionKind) (graphql.Output, error) {
704-
// Try to find the target resource type in our cache first
705-
// For now, we'll look for a type with the target kind name
706-
if existingType, exists := g.typesCache[targetKind]; exists && existingType != nil {
707-
return existingType, nil
708-
}
709-
710-
// If sourceGVK is available, try to construct a type name from the same group
711-
if sourceGVK != nil {
712-
groupTypeName := fmt.Sprintf("%s.%s.%s.%s", sourceGVK.Group, sourceGVK.Version, targetKind)
713-
if existingType, exists := g.typesCache[groupTypeName]; exists && existingType != nil {
714-
return existingType, nil
715-
}
716-
}
717-
718-
// Look through our definitions to find a matching resource
719-
for defKey, defSchema := range g.definitions {
720-
if gvk, err := g.getGroupVersionKind(defKey); err == nil && gvk.Kind == targetKind {
721-
// Found a matching definition, create the type
722-
fields, _, err := g.generateGraphQLFields(&defSchema, targetKind, []string{}, make(map[string]bool))
723-
if err != nil {
724-
continue
725-
}
726-
727-
targetType := graphql.NewObject(graphql.ObjectConfig{
728-
Name: targetKind,
729-
Fields: fields,
730-
})
731-
732-
// Cache the type
733-
g.typesCache[targetKind] = targetType
734-
return targetType, nil
735-
}
736-
}
737-
738-
// If we can't find or create the target type, return an error
739-
return nil, fmt.Errorf("could not find or create GraphQL type for target kind: %s", targetKind)
740-
}
741-
742694
// createEnhancedRefType creates a GraphQL type for enhanced references
743695
func (g *Gateway) createEnhancedRefType(targetKind string) graphql.Output {
744696
typeName := targetKind + "Relation"

0 commit comments

Comments
 (0)