@@ -663,18 +663,19 @@ def _get_project_graphql_fields(
663663 if fields is None :
664664 return set (), ProjectFetchType .REST
665665
666- rest_list_fields = {
666+ rest_fields = {
667667 "name" ,
668668 "code" ,
669669 "active" ,
670670 "createdAt" ,
671671 "updatedAt" ,
672672 }
673673 graphql_fields = set ()
674- if len (fields - rest_list_fields ) == 0 :
674+ if len (fields - rest_fields ) == 0 :
675675 return graphql_fields , ProjectFetchType .RESTList
676676
677677 must_use_graphql = False
678+ add_all_attrib = False
678679 for field in tuple (fields ):
679680 # Product types are available only in GraphQl
680681 if field == "usedTags" :
@@ -707,11 +708,9 @@ def _get_project_graphql_fields(
707708 elif field .startswith ("bundle" ):
708709 graphql_fields .add (field )
709710
710- elif field == "attrib" :
711- fields .discard ("attrib" )
712- graphql_fields |= self .get_attributes_fields_for_type (
713- "project"
714- )
711+ elif field == "attrib" or field .startswith ("attrib." ):
712+ fields .discard (field )
713+ add_all_attrib = True
715714
716715 # NOTE 'config' in GraphQl is NOT the same as from REST api.
717716 # - At the moment of this comment there is missing 'productBaseTypes'.
@@ -726,6 +725,8 @@ def _get_project_graphql_fields(
726725 remainders = fields - (inters | graphql_fields )
727726 if not remainders :
728727 graphql_fields |= inters
728+ if add_all_attrib :
729+ graphql_fields .add ("allAttrib" )
729730 return graphql_fields , ProjectFetchType .GraphQl
730731
731732 if must_use_graphql :
@@ -820,14 +821,19 @@ def _get_graphql_projects(
820821 all_attrib = json .loads (all_attrib )
821822 project ["allAttrib" ] = all_attrib
822823
823- if own_attributes and all_attrib :
824- own_attrib = {}
825- if all_attrib :
826- own_attrib = copy .deepcopy (all_attrib )
827- attrib = project .get ("attrib" , {})
828- for key in attrib .keys ():
829- own_attrib .setdefault (key , None )
830- project ["ownAttrib" ] = own_attrib
824+ if all_attrib is not None :
825+ project ["ownAttrib" ] = list (all_attrib )
826+
827+ attrib = copy .deepcopy (all_attrib )
828+ project ["attrib" ] = attrib
829+ for name , attr_data in (
830+ self .get_attributes_for_type ("project" ).items ()
831+ ):
832+ # NOTE 'default' can be 'None'
833+ attrib .setdefault (name , attr_data ["default" ])
834+
835+ if own_attributes :
836+ fill_own_attribs (project )
831837
832838 self ._fill_project_entity_data (project )
833839 yield project
0 commit comments