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

Commit 8103c24

Browse files
Jozef VolakJozefiel
Jozef Volak
authored andcommitted
[graphql-pydantic-converter] Refactor graphql_type rendering classes
1 parent e1953bb commit 8103c24

File tree

10 files changed

+589
-251
lines changed

10 files changed

+589
-251
lines changed

utils/graphql-pydantic-converter/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121
# 1.0.2
2222
- Stringify mutation input strings
2323
- Add __typename to payload
24-
- create test folder as a module
24+
- create test folder as a module
25+
26+
# 1.1.0
27+
- Support inline and extracted variables for mutation and query
28+
- Stringify fix

utils/graphql-pydantic-converter/README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ mutation = CreateScheduleMutation(
118118
)
119119
)
120120

121-
mutation.render()
122121

123122
```
124123

125124

126-
Created query
125+
Created query with inlined variables as string
126+
127+
```
128+
129+
mutation.render(form='inline')
127130
128-
```graphql
129131
mutation {
130132
createSchedule(
131133
input: {
@@ -144,6 +146,35 @@ mutation {
144146
cronString
145147
}
146148
}
149+
150+
```
151+
Created query with extracted variables
152+
153+
```
154+
mutation, variables = mutation.render(form='extracted)
155+
156+
# mutation as a string
157+
mutation ($input: CreateScheduleInput!) {
158+
createSchedule(input: $input) {
159+
name
160+
enabled
161+
workflowName
162+
workflowVersion
163+
cronString
164+
}
165+
}
166+
167+
# variables as a dict[str, Any]
168+
{
169+
"input": {
170+
"name": "name",
171+
"workflowName": "workflowName",
172+
"workflowVersion": "workflowVersion",
173+
"cronString": "* * * * *",
174+
"enabled": true,
175+
"parallelRuns": false
176+
}
177+
}
147178
```
148179

149180
### Response parser

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import requests
1616
from pydantic import BaseModel
1717

18-
from . import graphql_types
19-
from .schema_converter import GraphqlJsonParser
18+
from graphql_pydantic_converter import introspection
19+
from graphql_pydantic_converter.schema_converter import GraphqlJsonParser
2020

2121
EXPECTED_HEADERS_PARTS = 2
2222

@@ -83,7 +83,7 @@ def main(args: Optional[Sequence[str]] = None) -> Exit:
8383

8484
response = requests.post(
8585
config.url,
86-
data=json.dumps({'query': graphql_types.generate_schema_request(config.depth)}),
86+
data=json.dumps({'query': introspection.generate_schema_request(config.depth)}),
8787
headers={'Content-Type': 'application/json'} | headers
8888
)
8989
if response.ok:

0 commit comments

Comments
 (0)