Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit 501327b

Browse files
author
Jozef Volak
committed
[graphql-pydantic-converter] Ignore enum private schema objects
1 parent 8aa4219 commit 501327b

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

utils/graphql-pydantic-converter/graphql_pydantic_converter/schema_converter.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,18 @@ def __create_scalar(self, scalars: list[Type]) -> None:
307307
def __create_enum(self, enums: list[Type]) -> None:
308308
kv_template = Template("$indent$name = '$name'\n")
309309
for enum in enums:
310-
tmp_enum = [self.__class_template.substitute(name=enum.name, type='ENUM')]
311-
if enum.enum_values:
312-
for i in enum.enum_values:
313-
tmp_enum.append(kv_template.substitute(indent=self.__INDENT, name=i.name))
314-
self.__result += (''.join(tmp_enum))
315-
if enum.name:
316-
self.__enums.append(enum.name)
310+
311+
if enum.name:
312+
if enum.name.startswith('__') and self.__ignore_private_objects:
313+
return
314+
315+
tmp_enum = [self.__class_template.substitute(name=enum.name, type='ENUM')]
316+
if enum.enum_values:
317+
for i in enum.enum_values:
318+
tmp_enum.append(kv_template.substitute(indent=self.__INDENT, name=i.name))
319+
self.__result += (''.join(tmp_enum))
320+
if enum.name:
321+
self.__enums.append(enum.name)
317322

318323
def __create_interface(self, interfaces: list[Type]) -> None:
319324
enums = self.__enums + self.__ignore_enums

utils/graphql-pydantic-converter/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ packages = [{ include = "graphql_pydantic_converter" }]
1919
name = "graphql-pydantic-converter"
2020
description = "Convert pydantic schema to pydantic datamodel and build request from it"
2121
authors = ["Jozef Volak <[email protected]>"]
22-
version = '0.1.2'
22+
version = '0.1.3'
2323
readme = ["README.md", "CHANGELOG.md"]
2424
keywords = ["graphql", "pydantic"]
2525
license = "Apache 2.0"

0 commit comments

Comments
 (0)