code: def collect_fields(node):
      
      fields = set()
      for leaf in node:
          if leaf.get('kind', None) == "Field":
              fields.add(leaf["name"]["value"])
  
          if leaf.get("selection_set", None):
              fields = fields.union(collect_fields(leaf["selection_set"]["selections"]))
  
      return fields
docs: Get all the unique field names that are eligible for optimization
  
      Requested a function like this be added to the ``info`` object
      upstream in graphene_django:
      https://github.com/graphql-python/graphene-django/issues/230