Skip to content

Commit

Permalink
utils and extra field for unions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikikuzi committed Mar 18, 2024
1 parent 1d50d2a commit c85c062
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions codegen/src/priority.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ class ExtractionResults():
enum_classes: dict
scalar_defs: dict
type_refs: dict
unions: list

def __init__(self):
self.scalar_defs = {}
self.enum_classes = {}
self.simple_type_classes = {}
self.type_classes = {}
self.unions = []
self.query_classes = {}
self.queries_enum_class = {}
self.mutation_classes = {}
Expand Down
15 changes: 12 additions & 3 deletions codegen/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ def perf_profile_log():
def split_types(dictionary: dict[str, any]):
myDeque = deque()
simpleTypes = []
while dictionary:
for currentItem in dictionary.items():
try:
currentItem = dictionary.popitem()
currUsedTypes = 0
for field in currentItem[1].get_valid_fields_lst():
currUsedTypes += len(field.get_used_typenames())
Expand Down Expand Up @@ -73,4 +72,14 @@ def add_val_update_dict(dictionary: dict, key, value):
elif isinstance(value, int):
dictionary[key] += value
except Exception as ex:
raise ex
raise ex


def to_camel_case(text: str) -> str:
return ''.join(word[0].title() + word[1:].lower() for word in text.split("_")) if '_' in text \
else ''.join(word[0].title() + word[1:] for word in text.split("_"))


def to_snake_case(text: str) -> str:
return ''.join(['_'+i.lower() if i.isupper()
else i for i in text]).lstrip('_')

0 comments on commit c85c062

Please sign in to comment.