(self)
return _api_features_cache
Check if we can use recently added schema fields.

        For GitHub Enterprise installations, the latest GraphQL fields may not
        be available.

        To query the GraphQL API, we need an installation token, so for the
        first client to make an API request, we use their credentials to view
        schema metadata and cache the results.
Check if we can use recently added schema fields.
Check if we can use recently added schema fields .
async def get_api_features(self) -> ApiFeatures | None:
        """
        Check if we can use recently added schema fields.

        For GitHub Enterprise installations, the latest GraphQL fields may not
        be available.

        To query the GraphQL API, we need an installation token, so for the
        first client to make an API request, we use their credentials to view
        schema metadata and cache the results.
        """
        global _api_features_cache  # pylint: disable=global-statement
        if _api_features_cache is not None:
            return _api_features_cache
        res = await self.send_query(
            query="""
query {
   __type(name:"BranchProtectionRule") {
      fields(includeDeprecated: true) {
         name
      }  
   }
}
""",
            variables=dict(),
            installation_id=self.installation_id,
        )
        if res is None:
            self.log.warning("failed to fetching api features")
            return None
        errors = res.get("errors")
        data = res.get("data")
        if errors or not data:
            self.log.warning("errors fetching api features", errors=errors, data=data)
            return None

        try:
            fields = data["__type"]["fields"]
        except (TypeError, KeyError):
            self.log.warning("problem parsing api features", exc_info=True)
            return None
        _api_features_cache = ApiFeatures(
            requires_conversation_resolution=any(
                field["name"] == "requiresConversationResolution" for field in fields
            )
        )
        return _api_features_cache
async def get_api_features ( self ) -> ApiFeatures | None : global _api_features_cache # pylint: disable=global-statement if _api_features_cache is not None : return _api_features_cache res = await self . send_query ( query = """
query {
   __type(name:"BranchProtectionRule") {
      fields(includeDeprecated: true) {
         name
      }  
   }
}
""" , variables = dict ( ) , installation_id = self . installation_id , ) if res is None : self . log . warning ( "failed to fetching api features" ) return None errors = res . get ( "errors" ) data = res . get ( "data" ) if errors or not data : self . log . warning ( "errors fetching api features" , errors = errors , data = data ) return None try : fields = data [ "__type" ] [ "fields" ] except ( TypeError , KeyError ) : self . log . warning ( "problem parsing api features" , exc_info = True ) return None _api_features_cache = ApiFeatures ( requires_conversation_resolution = any ( field [ "name" ] == "requiresConversationResolution" for field in fields ) ) return _api_features_cache