@@ -405,24 +405,16 @@ func (g *Gateway) generateGraphQLFields(resourceScheme *spec.Schema, typePrefix
405
405
relationFieldName := strings .ToLower (string (targetKind [0 ])) + targetKind [1 :] + "Relation"
406
406
407
407
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 ),
425
411
}
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" )
426
418
}
427
419
} else {
428
420
g .log .Info ().
@@ -699,46 +691,6 @@ func (g *Gateway) extractTargetKind(fieldName string) string {
699
691
return resolver .ExtractTargetKind (fieldName )
700
692
}
701
693
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
-
742
694
// createEnhancedRefType creates a GraphQL type for enhanced references
743
695
func (g * Gateway ) createEnhancedRefType (targetKind string ) graphql.Output {
744
696
typeName := targetKind + "Relation"
0 commit comments