Skip to content

Commit d91125e

Browse files
authored
Merge branch 'main' into feat/models-only-mode
2 parents b7da2c3 + dd3a564 commit d91125e

81 files changed

Lines changed: 2283 additions & 554 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/prepare_release.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Prepare release
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
77
workflow_call:
88
workflow_dispatch:
99

@@ -22,7 +22,23 @@ jobs:
2222
needs:
2323
- build
2424
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write
2527
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: Generate release notes
33+
id: release-notes
34+
uses: orhun/git-cliff-action@v4
35+
with:
36+
config: cliff.toml
37+
args: --latest --strip all
38+
env:
39+
OUTPUT: RELEASE_NOTES.md
40+
GITHUB_REPO: ${{ github.repository }}
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2642
- name: Download all the dists
2743
uses: actions/download-artifact@v4
2844
with:
@@ -35,6 +51,7 @@ jobs:
3551
files: |
3652
./dist/*
3753
draft: true
54+
body_path: RELEASE_NOTES.md
3855
- name: Summary
3956
run: |
4057
echo "# Release summary" >> $GITHUB_STEP_SUMMARY

.github/workflows/test.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ jobs:
3838
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
3939

4040
- name: Run static analysis
41-
run: hatch fmt --check
42-
43-
- name: Run type checking
44-
run: hatch run types:check
41+
run: hatch run lint
4542

4643
- name: Run tests
4744
run: hatch test -c -py ${{ matrix.python-version }}

CHANGELOG.md

Lines changed: 6 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,13 @@
11
# CHANGELOG
22

3-
## 0.15.2 (2025-08-28)
3+
All notable unreleased changes to this project will be documented in this file.
44

5-
- Changed code typing to satisfy MyPy 1.11.0 version
6-
- Added support for `async_client=false` to work with `enable_custom_operations=true`
7-
- Fix propagating `convert_to_snake_case` to clients during package generation
8-
- Added ClientForwardRefsPlugin to standard plugins.
9-
- Re-added model_rebuild calls for input types with forward references.
10-
- Fixed fragments on interfaces being omitted from generated client.
11-
- Fixed @include directive result type when using convert_to_snake_case option.
12-
- Added Custom query builder feature.
5+
For released versions, see the [Releases](https://github.com/mirumee/ariadne-codegen/releases) page.
136

14-
## 0.14.0 (2024-07-17)
7+
## Unreleased
158

16-
- Added `ClientForwardRefsPlugin` to standard plugins.
17-
- Re-added `model_rebuild` calls for input types with forward references.
18-
- Fixed fragments on interfaces being omitted from generated client.
19-
- Fixed `@Include` directive result type when using `convert_to_snake_case` option.
20-
- Added Custom query builder feature.
9+
### ⚠️ Breaking Changes
2110

11+
### 📚 Documentation
2212

23-
## 0.13.0 (2024-03-4)
24-
25-
- Fixed `str_to_snake_case` utility to capture fully capitalized words followed by an underscore.
26-
- Re-added `model_rebuild` calls for models with forward references.
27-
- Fixed potential name conflicts between field args and generated client's method code.
28-
29-
30-
## 0.12.0 (2024-02-05)
31-
32-
- Fixed `graphql-transport-ws` protocol implementation not waiting for the `connection_ack` message on new connection.
33-
- Fixed `get_client_settings` mutating `config_dict` instance.
34-
- Added support to `graphqlschema` for saving schema as a GraphQL file.
35-
- Restored `model_rebuild` calls for top level fragment models.
36-
37-
38-
## 0.11.0 (2023-12-05)
39-
40-
- Removed `model_rebuild` calls for generated input, fragment and result models.
41-
- Added `NoReimportsPlugin` that makes the `__init__.py` of generated client package empty.
42-
- Added `include_all_inputs` config flag to generate only inputs used in supplied operations.
43-
- Added `include_all_enums` config flag to generate only enums used in supplied operations.
44-
- Added `operationName` to payload sent by generated client's methods.
45-
- Fixed base clients to pass `mypy --strict` without installed optional dependencies.
46-
- Renamed `GraphQlClientInvalidResponseError` to `GraphQLClientInvalidResponseError` (breaking change).
47-
- Changed base clients to raise `GraphQLClientGraphQLMultiError` for payloads with `errors` key but no `data` (breaking change).
48-
49-
50-
## 0.10.0 (2023-11-15)
51-
52-
- Fixed generating results for nullable fields with nullable directives.
53-
- Changed `include_comments` option to accept enum value, changed default to `"stable"`, deprecated boolean support. Added `get_file_comment` plugin hook.
54-
- Changed `str_to_snake_case` utility to correctly handle capitalized words.
55-
- Digits in Python names are now preceded by an underscore (breaking change).
56-
- Fixed parsing of unions and interfaces to always add `__typename` to generated result models.
57-
- Added escaping of enum values which are Python keywords by appending `_` to them.
58-
- Fixed `enums_module_name` option not being passed to generators.
59-
- Added additional base clients supporting the Open Telemetry tracing. Added `opentelemetry_client` config option.
60-
- Changed generated client's methods to pass `**kwargs` to base client's `execute` and `execute_ws` methods (breaking change for custom base clients).
61-
- Added `operation_definition` argument to `generate_client_method` plugin hook.
62-
- Added `ExtractOperationsPlugin` that extracts operation strings from client methods to separate module.
63-
- Added Python 3.12 to tested versions.
64-
65-
66-
## 0.9.0 (2023-09-11)
67-
68-
- Fixed generating operation string for nested inline fragments.
69-
- Removed scalars module. Changed generated models and client to use annotated types for custom scalars. Removed `scalars_module_name` option. Removed `generate_scalars_module`, `generate_scalars_cod`, `generate_scalar_annotation` and `generate_scalar_imports` plugin hooks.
70-
- Removed pydantic warnings for fields with `model_` prefix.
71-
- Fixed generating result types with nullable directives.
72-
73-
74-
## 0.8.0 (2023-08-22)
75-
76-
- Added support for `Upload` scalar. Added support for file uploads to `AsyncBaseClient` and `BaseClient`.
77-
- Added validation of defined operations against the schema.
78-
- Removed `mixin` directive from fragment string included in operation string sent to server.
79-
- Added support for `mixin` directive on fragments definitions.
80-
- Added support for fragments defined on subtype of field's type.
81-
- Added default representation for a field name consisting only of underscores.
82-
- Changed generated client and models to use pydantic v2.
83-
- Changed custom scalars implementation to utilize pydantic's `BeforeValidator` and `PlainSerializer`. Added `scalars_module_name` option. Replaced `generate_scalars_parse_dict` and `generate_scalars_serialize_dict` with `generate_scalar_annotation` and `generate_scalar_imports` plugin hooks.
84-
- Unified annotations in generated client to be compatible with python < 3.9.
85-
- Fixed generating default values of input types from remote schemas.
86-
- Changed generating of input and result field names to add `_` to names reserved by pydantic.
87-
88-
89-
## 0.7.1 (2023-06-06)
90-
91-
- Fixed `AsyncBaseClient` and `BaseClient` to send `Content-Type` header with requests.
92-
93-
94-
## 0.7.0 (2023-06-01)
95-
96-
- Added support for subscriptions as async generators.
97-
- Changed how fragments are handled to generate separate module with fragments as mixins.
98-
- Fixed `ResultTypesGenerator` to trigger `generate_result_class` for each result model.
99-
- Changed processing of models fields to trim leading underscores.
100-
- Added `ShorterResultsPlugin` to standard plugins.
101-
- Fixed handling of inline fragments inside other fragments.
102-
- Changed generated unions to use pydantic's discriminated unions feature.
103-
- Replaced HTTPX's `json=` serializer for query payloads with pydantic's `pydantic_encoder`.
104-
- Removed `mixin` directive from operation string sent to server.
105-
- Fixed `ShorterResultsPlugin` that generated faulty code for discriminated unions.
106-
- Changed generator to ignore unused fragments which should be unpacked in queries.
107-
- Changed type hints for parse and serialize methods of scalars to `typing.Any`.
108-
- Added `process_schema` plugin hook.
109-
110-
111-
## 0.6.0 (2023-04-18)
112-
113-
- Changed logic how custom scalar imports are generated. Deprecated `import_` key.
114-
- Added escaping of GraphQL names which are Python keywords by appending `_` to them.
115-
- Fixed parsing of list variables.
116-
- Changed base clients to remove unset arguments and input fields from variables payload.
117-
- Added `process_name` plugin hook.
118-
119-
120-
## 0.5.0 (2023-04-05)
121-
122-
- Added generation of GraphQL schema's Python representation.
123-
- Fixed annotations for lists.
124-
- Fixed support of custom operation types names.
125-
- Unlocked versions of black, isort, autoflake and dev dependencies
126-
- Added `remote_schema_verify_ssl` option.
127-
- Changed how default values for inputs are generated to handle potential cycles.
128-
- Fixed `BaseModel` incorrectly calling `parse` and `serialize` methods on entire list instead of its items for `list[Scalar]`.
129-
130-
131-
## 0.4.0 (2023-03-20)
132-
133-
- Fixed generating models from interfaces with inline fragments.
134-
- Added default `None` values for generated methods optional arguments.
135-
- Added basic plugin system.
136-
- Added `InitFileGenerator`, `EnumsGenerator`, `ClientGenerator` and `ArgumentsGenerator` plugin hooks.
137-
- Added `InputTypesGenerator` and `ResultTypesGenerator` plugin hooks.
138-
- Added `ScalarsDefinitionsGenerator` and `PackageGenerator` plugin hooks.
139-
- Added support for `[tool.ariadne-codegen]` section key. Deprecated `[ariadne-codegen]`.
140-
- Added support for environment variables to remote schema headers values.
141-
- Added `--config` argument to `ariadne-codegen` script, to support reading configuration from custom path.
142-
143-
144-
## 0.3.0 (2023-02-21)
145-
146-
- Changed generated code to pass `mypy --strict`.
147-
- Changed base clients to get full url from user.
148-
- Added support for custom scalars.
149-
150-
151-
## 0.2.1 (2023-02-13)
152-
153-
- Fixed incorrectly raised exception when using custom scalar as query argument type.
154-
155-
156-
## 0.2.0 (2023-02-02)
157-
158-
- Added `remote_schema_url` and `remote_schema_headers` settings to support reading remote schemas.
159-
- Added `headers` argument to `__init__` methods of `BaseClient` and `AsyncBaseClient`.
13+
### 🛠️ Build System

CONTRIBUTING.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,44 @@ We welcome bug reports, questions, pull requests, and general feedback.
66

77
We also ask all contributors to familiarize themselves with and follow code of conduct, available in the [CODE_OF_CONDUCT.md](https://github.com/mirumee/ariadne/blob/master/CODE_OF_CONDUCT.md) file kept in the main project's repository.
88

9-
10-
# Reporting bugs, asking for help, offering feedback and ideas
9+
## Reporting bugs, asking for help, offering feedback and ideas
1110

1211
You can use [GitHub issues](https://github.com/mirumee/ariadne-codegen/issues) to report bugs, ask for help, share your ideas, or simply offer feedback. We are curious what you think of Ariadne!
1312

14-
1513
## Development setup
1614

17-
Ariadne Code Generator is written to support Python 3.9, 3.10, 3.11, 3.12 and 3.13.
15+
Ariadne Code Generator is written to support Python 3.10, 3.11, 3.12, 3.13 and 3.14.
1816

1917
We use [Hatch](https://github.com/pypa/hatch) for project management.
2018

21-
The codebase is formatted using [ruff](https://github.com/astral-sh/ruff).
22-
To format the code, use the following command:
19+
Formatting and linting (including typing-related rules) use [ruff](https://github.com/astral-sh/ruff). To format the code, run:
20+
2321
```bash
2422
hatch fmt
2523
```
2624

27-
The contents of the `ariadne-codegen` package are annotated with types and validated using [mypy](http://mypy-lang.org/index.html). To run type checking with mypy, use:
25+
The contents of the `ariadne-codegen` package are annotated with types and validated using [ty](https://github.com/astral-sh/ty). To run type checking, use:
26+
2827
```bash
2928
hatch run types:check
3029
```
3130

32-
3331
Tests are developed using [pytest](https://pytest.org/) and are managed with Hatch.
3432

35-
3633
To run the tests, use:
34+
3735
```bash
3836
hatch test
3937
```
4038

39+
To run linting (formatting check + type checking):
40+
41+
```bash
42+
hatch run lint
43+
```
44+
45+
To run all checks (formatting, type checking, and tests):
4146

42-
To run all checks (formatting, type checking, and tests), you can use:
4347
```bash
4448
hatch run check
4549
```
@@ -48,14 +52,12 @@ We require all changes to be done via pull requests, and to be approved by membe
4852

4953
All changes should pass these linter checks.
5054

51-
5255
## Working on issues
5356

5457
We consider all issues which are not assigned to anybody as being available for contributors. The **[help wanted](https://github.com/mirumee/ariadne-codegen/labels/help%20wanted)** label is used to single out issues that we consider easier or higher priority on the list of things that we would like to see.
5558

5659
If you've found issue you want to help with, please add your comment to it - this lets other contributors know what issues are being worked on, as well as allowing maintainers to offer guidance and help.
5760

58-
5961
## Pull requests
6062

6163
We don't require pull requests to be followed with bug reports. If you've found a typo or a silly little bug that has no issue or pull request already, you can open your own pull request. We only ask that this PR provides context or explanation for what problem it fixes, or which area of the project it improves.

PLUGINS.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
Plugin is a class extending `ariadne_codegen.plugins.base.Plugin`.
66

77
Plugins are instantiated once, at the beginning of `ariadne-codegen` command, with following arguments:
8+
89
- `schema: GraphQLSchema`: parsed graphql schema
910
- `config_dict: dict`: parsed `pyproject.toml` file represented as a dictionary
1011

1112
To handle specific events custom plugins need to override [hook methods](#hooks) from default `Plugin`. Default hook methods from `Plugin` don't implement any logic on their own.
1213

13-
1414
## Enabling plugins
1515

1616
Plugins can be enabled in `ariadne-codegen` by assigning list of strings to `plugins` key in config file.
@@ -20,7 +20,6 @@ Every element of the list can enable plugins in 2 ways:
2020

2121
2. Providing only package name, eg. `my_package`. In this case all plugins from selected package will be used. For class to be accessible this way, it needs to be in package's public api. Plugin has to be importable from package, eg. `from my_package import MyPlugin` has to work.
2222

23-
2423
## Hooks
2524

2625
### generate_init_module
@@ -99,6 +98,7 @@ def generate_client_method(
9998

10099
Hook executed on generation of client's method, which represents single graphql operation. Depends on the configuration method can be either async or not.
101100
`
101+
102102
### generate_arguments
103103

104104
```py
@@ -185,8 +185,7 @@ def generate_result_class(
185185
) -> ast.ClassDef:
186186
```
187187

188-
Hook executed on generation of single model, part of result of given query or mutation.
189-
188+
Hook executed on generation of single model, part of result of given query or mutation.
190189

191190
### generate_result_field
192191

@@ -201,7 +200,6 @@ def generate_result_field(
201200

202201
Hook executed on generation of single model field.
203202

204-
205203
### generate_client_code
206204

207205
```py
@@ -228,7 +226,7 @@ Hook executed on generation of input models code. Result is used as content of `
228226

229227
### generate_result_types_code
230228

231-
```py
229+
```py
232230
def generate_result_types_code(self, generated_code: str) -> str:
233231
```
234232

@@ -242,12 +240,12 @@ def copy_code(self, copied_code: str) -> str:
242240

243241
Hook executed on coping file's content to result package.
244242
Files hook is called for:
243+
245244
- `base_client.py` or `async_base_client.py` or custom base client `base_client_file_path`
246245
- `base_model.py`
247246
- `exceptions.py`
248247
- all files from config's `files_to_include`
249248

250-
251249
### generate_init_code
252250

253251
```py
@@ -276,16 +274,14 @@ def generate_fragments_module(
276274

277275
Hook executed on generation of fragments module. Module has classes representing all fragments from provided queries. Later this module will be saved as `{fragments_module_name}.py`, `fragments_module_name` is taken from config.
278276

279-
280277
### process_schema
281278

282279
```py
283280
def process_schema(self, schema: GraphQLSchema) -> GraphQLSchema:
284281
```
285282

286283
Hook executed on creating `GraphQLSchema` object from path or url provided in settings. During parsing `assume_valid` is set to `True`. Then this hook is called, and only after that `graphql.assert_valid_schema` is used to validate schema.
287-
To ensure all plugins have current version of schema, result of this hook is propagated to all plugins, updating their `schema` field.
288-
284+
To ensure all plugins have current version of schema, result of this hook is propagated to all plugins, updating their `schema` field.
289285

290286
### get_file_comment
291287

@@ -297,7 +293,6 @@ def get_file_comment(
297293

298294
Hook executed on generating comment included at the beginning of a generated code.
299295

300-
301296
## Example
302297

303298
This example plugin adds `__version__ = "..."` to generated `__init__.py` file.

0 commit comments

Comments
 (0)