You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`queries_path` - path to file/directory with queries
56
+
-`queries_path` - path to file/directory with queries (Can be optional if `enable_custom_operations` is used)
57
57
58
58
One of the following 2 parameters is required, in case of providing both of them `schema_path` is prioritized:
59
59
@@ -81,6 +81,93 @@ Optional settings:
81
81
-`opentelemetry_client` (defaults to `false`) - default base clients don't support any performance tracing. Change this option to `true` to use the base client with Open Telemetry support.
82
82
-`files_to_include` (defaults to `[]`) - list of files which will be copied into generated package
83
83
-`plugins` (defaults to `[]`) - list of plugins to use during generation
84
+
-`enable_custom_operations` (defaults to `false`) - enables building custom operations. Generates additional files that contains all the classes and methods for generation.
85
+
86
+
87
+
## Custom operation builder
88
+
89
+
The custom operation builder allows you to create complex GraphQL queries in a structured and intuitive way.
90
+
91
+
### Example Code
92
+
93
+
```python
94
+
import asyncio
95
+
from graphql_client import Client
96
+
from graphql_client.custom_fields import (
97
+
ProductFields,
98
+
ProductTranslatableContentFields,
99
+
ProductTranslationFields,
100
+
TranslatableItemConnectionFields,
101
+
TranslatableItemEdgeFields,
102
+
)
103
+
from graphql_client.custom_queries import Query
104
+
from graphql_client.enums import LanguageCodeEnum, TranslatableKinds
105
+
106
+
107
+
asyncdefget_products():
108
+
# Create a client instance with the specified URL and headers
1. The Query.product(id="...", channel="channel-uk") initiates a query for a product with the specified ID and channel.
149
+
2. .fields(ProductFields.id, ProductFields.name) specifies the fields to retrieve for the product: id and name.
150
+
2. Building the Translation Query:
151
+
1. The Query.translations(kind=TranslatableKinds.PRODUCT, first=10) initiates a query for product translations.
152
+
2. .fields(...) specifies the fields to retrieve for the translations.
153
+
3. .alias("aliased_edges") renames the edges field to aliased_edges.
154
+
4. .on("ProductTranslatableContent", ...) specifies the fields to retrieve if the node is of type ProductTranslatableContent: id, product_id, and name.
155
+
3. Executing the Queries:
156
+
1. The client.query(...) method is called with the built queries and an operation name "get_products".
157
+
2. This method sends the queries to the server and retrieves the response.
158
+
159
+
160
+
### Example pyproject.toml configuration.
161
+
162
+
`Note: queries_path is optional when enable_custom_operations is set to true`
0 commit comments