Skip to content

Commit 311dbf3

Browse files
committed
Allow representing null values in graphql
1 parent ab99599 commit 311dbf3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

infrahub_sdk/graphql.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
VARIABLE_TYPE_MAPPING = ((str, "String!"), (int, "Int!"), (float, "Float!"), (bool, "Boolean!"))
99

1010

11-
def convert_to_graphql_as_string(value: str | bool | list | BaseModel | Enum | Any, convert_enum: bool = False) -> str: # noqa: PLR0911
11+
def convert_to_graphql_as_string( # noqa: PLR0911
12+
value: str | bool | list | BaseModel | Enum | Any | None, convert_enum: bool = False
13+
) -> str:
14+
if value is None:
15+
return "null"
1216
if isinstance(value, str) and value.startswith("$"):
1317
return value
1418
if isinstance(value, Enum):

0 commit comments

Comments
 (0)