graphql-typed-python 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. graphql_typed_python-0.1.2/.github/workflows/qa.yml +62 -0
  2. graphql_typed_python-0.1.2/.github/workflows/release.yml +108 -0
  3. graphql_typed_python-0.1.2/.gitignore +210 -0
  4. graphql_typed_python-0.1.2/.pre-commit-config.yaml +40 -0
  5. graphql_typed_python-0.1.2/.python-version +1 -0
  6. graphql_typed_python-0.1.2/.vscode/settings.json +20 -0
  7. graphql_typed_python-0.1.2/Justfile +33 -0
  8. graphql_typed_python-0.1.2/LICENSE +21 -0
  9. graphql_typed_python-0.1.2/PKG-INFO +141 -0
  10. graphql_typed_python-0.1.2/README.md +129 -0
  11. graphql_typed_python-0.1.2/graphql_typed/__init__.py +20 -0
  12. graphql_typed_python-0.1.2/graphql_typed/cli.py +42 -0
  13. graphql_typed_python-0.1.2/graphql_typed/generator/__init__.py +1 -0
  14. graphql_typed_python-0.1.2/graphql_typed/generator/api.py +65 -0
  15. graphql_typed_python-0.1.2/graphql_typed/generator/client.py +131 -0
  16. graphql_typed_python-0.1.2/graphql_typed/generator/factory.py +41 -0
  17. graphql_typed_python-0.1.2/graphql_typed/generator/loader.py +39 -0
  18. graphql_typed_python-0.1.2/graphql_typed/generator/operations.py +148 -0
  19. graphql_typed_python-0.1.2/graphql_typed/generator/types.py +159 -0
  20. graphql_typed_python-0.1.2/graphql_typed/generator/write.py +65 -0
  21. graphql_typed_python-0.1.2/graphql_typed/py.typed +0 -0
  22. graphql_typed_python-0.1.2/graphql_typed/templates/transport.py +124 -0
  23. graphql_typed_python-0.1.2/pyproject.toml +38 -0
  24. graphql_typed_python-0.1.2/scripts/benchmark_generate.py +60 -0
  25. graphql_typed_python-0.1.2/scripts/release.py +180 -0
  26. graphql_typed_python-0.1.2/tests/__init__.py +0 -0
  27. graphql_typed_python-0.1.2/tests/conftest.py +33 -0
  28. graphql_typed_python-0.1.2/tests/contract/devices/operations.py +41 -0
  29. graphql_typed_python-0.1.2/tests/contract/devices/schema.graphql +11 -0
  30. graphql_typed_python-0.1.2/tests/contract/devices/standalone.py +62 -0
  31. graphql_typed_python-0.1.2/tests/contract/devices/usage.py +26 -0
  32. graphql_typed_python-0.1.2/tests/contract/mutations/execute.py +17 -0
  33. graphql_typed_python-0.1.2/tests/contract/mutations/operations.py +39 -0
  34. graphql_typed_python-0.1.2/tests/contract/mutations/schema.graphql +11 -0
  35. graphql_typed_python-0.1.2/tests/contract/mutations/usage.py +19 -0
  36. graphql_typed_python-0.1.2/tests/contract/recursive/operations.py +23 -0
  37. graphql_typed_python-0.1.2/tests/contract/recursive/schema.graphql +3 -0
  38. graphql_typed_python-0.1.2/tests/contract/recursive/usage.py +10 -0
  39. graphql_typed_python-0.1.2/tests/ide/__init__.py +0 -0
  40. graphql_typed_python-0.1.2/tests/ide/conftest.py +158 -0
  41. graphql_typed_python-0.1.2/tests/ide/test_completions.py +38 -0
  42. graphql_typed_python-0.1.2/tests/test_contracts.py +47 -0
  43. graphql_typed_python-0.1.2/tests/test_execution.py +136 -0
  44. graphql_typed_python-0.1.2/tests/test_generation.py +148 -0
  45. graphql_typed_python-0.1.2/uv.lock +775 -0
@@ -0,0 +1,62 @@
1
+ name: QA
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ QA:
11
+ name: QA checks
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Check out repository
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v5
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version-file: .python-version
25
+
26
+ - name: Sync packages
27
+ run: uv sync --locked --all-packages
28
+
29
+ - name: Check import sorting
30
+ run: uv run ruff check --select I .
31
+
32
+ - name: Check formatting
33
+ run: uv run ruff format --check .
34
+
35
+ - name: Type check package
36
+ run: uv run ty check .
37
+
38
+ - name: Contract tests
39
+ run: uv run pytest -n auto
40
+
41
+ benchmark:
42
+ name: Compare generation time and size
43
+ if: github.event_name == 'pull_request'
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: actions/checkout@v4
48
+ with:
49
+ ref: ${{ github.event.pull_request.base.sha }}
50
+ path: .benchmark/base
51
+ - uses: astral-sh/setup-uv@v5
52
+ - uses: actions/setup-python@v5
53
+ with:
54
+ python-version-file: .python-version
55
+ - run: uv sync --locked
56
+ - name: Benchmark both generation passes
57
+ run: |
58
+ if test -f .benchmark/base/graphql_typed/cli.py; then
59
+ uv run python scripts/benchmark_generate.py --base .benchmark/base
60
+ else
61
+ uv run python scripts/benchmark_generate.py
62
+ fi
@@ -0,0 +1,108 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - releases
7
+
8
+ permissions:
9
+ contents: write
10
+ id-token: write
11
+
12
+ jobs:
13
+ release:
14
+ name: Build and publish
15
+ runs-on: ubuntu-latest
16
+ environment: pypi
17
+
18
+ steps:
19
+ - name: Check out repository
20
+ uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v5
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v5
29
+ with:
30
+ python-version-file: .python-version
31
+
32
+ - name: Sync packages
33
+ run: uv sync --locked --all-packages
34
+
35
+ - name: Resolve release version
36
+ run: |
37
+ python - <<'PY'
38
+ import os
39
+ import re
40
+ import sys
41
+ import tomllib
42
+ from pathlib import Path
43
+
44
+ with open("pyproject.toml", "rb") as file:
45
+ version = tomllib.load(file)["project"]["version"]
46
+
47
+ if not re.fullmatch(r"\d+\.\d+\.\d+((a|b|rc)\d+)?", version):
48
+ print(f"Unsupported release version: {version!r}")
49
+ print("Expected X.Y.Z, X.Y.ZaN, X.Y.ZbN, or X.Y.ZrcN.")
50
+ sys.exit(1)
51
+
52
+ tag = f"v{version}"
53
+ github_env = Path(os.environ["GITHUB_ENV"])
54
+ with github_env.open("a") as env:
55
+ env.write(f"RELEASE_VERSION={version}\n")
56
+ env.write(f"TAG_NAME={tag}\n")
57
+ PY
58
+
59
+ - name: Verify release tag is new
60
+ run: |
61
+ if git rev-parse --verify --quiet "refs/tags/$TAG_NAME"; then
62
+ echo "Tag $TAG_NAME already exists."
63
+ exit 1
64
+ fi
65
+ if git ls-remote --exit-code --tags origin "refs/tags/$TAG_NAME" >/dev/null 2>&1; then
66
+ echo "Tag $TAG_NAME already exists on origin."
67
+ exit 1
68
+ fi
69
+
70
+ - name: Check import sorting
71
+ run: uv run ruff check --select I .
72
+
73
+ - name: Check formatting
74
+ run: uv run ruff format --check .
75
+
76
+ - name: Type check package
77
+ run: uv run ty check .
78
+
79
+ - name: Contract tests
80
+ run: uv run pytest -n auto
81
+
82
+ - name: Build distributions
83
+ run: uv build
84
+
85
+ - name: Check distributions
86
+ run: uv run twine check dist/*
87
+
88
+ - name: Create release tag
89
+ run: |
90
+ git config user.name "github-actions[bot]"
91
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
92
+ git tag -a "$TAG_NAME" -m "Release $TAG_NAME" "$GITHUB_SHA"
93
+ git push origin "$TAG_NAME"
94
+
95
+ - name: Upload distributions
96
+ uses: actions/upload-artifact@v4
97
+ with:
98
+ name: dist
99
+ path: dist/*
100
+ if-no-files-found: error
101
+
102
+ - name: Publish to PyPI
103
+ uses: pypa/gh-action-pypi-publish@release/v1
104
+
105
+ - name: Create GitHub release
106
+ env:
107
+ GH_TOKEN: ${{ github.token }}
108
+ run: gh release create "$TAG_NAME" dist/* --generate-notes --title "$TAG_NAME"
@@ -0,0 +1,210 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ generated
210
+ .benchmark/
@@ -0,0 +1,40 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: sync
5
+ name: sync packages
6
+ language: system
7
+ entry: uv sync --locked --all-packages
8
+ stages: [pre-commit]
9
+ pass_filenames: false
10
+ priority: 0
11
+
12
+ - id: sort-imports
13
+ name: sort imports
14
+ language: system
15
+ entry: uv run ruff check --select I --fix .
16
+ stages: [pre-commit]
17
+ pass_filenames: false
18
+ priority: 1
19
+
20
+ - id: format
21
+ name: format
22
+ language: system
23
+ entry: uv run ruff format .
24
+ stages: [pre-commit]
25
+ pass_filenames: false
26
+ priority: 2
27
+
28
+ - id: typecheck
29
+ name: type check
30
+ language: system
31
+ entry: uv run ty check .
32
+ pass_filenames: false
33
+ priority: 3
34
+
35
+ - id: tests
36
+ name: contract tests
37
+ language: system
38
+ entry: uv run pytest -n auto
39
+ pass_filenames: false
40
+ priority: 4
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,20 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.quickSuggestions": {
4
+ "strings": true
5
+ },
6
+ "[python]": {
7
+ "editor.tabSize": 4,
8
+ "editor.defaultFormatter": "charliermarsh.ruff",
9
+ "editor.codeActionsOnSave": {
10
+ "source.fixAll.ruff": "explicit"
11
+ }
12
+ },
13
+ "python.testing.pytestArgs": [
14
+ "tests"
15
+ ],
16
+ "python.testing.unittestEnabled": false,
17
+ "python.testing.pytestEnabled": true,
18
+ "python.languageServer": "None",
19
+ "python.venvPath": "."
20
+ }
@@ -0,0 +1,33 @@
1
+ set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
2
+
3
+ default:
4
+ @just --list
5
+
6
+ sync:
7
+ uv sync --locked --all-packages
8
+
9
+ format:
10
+ uv run ruff check --select I --fix .
11
+ uv run ruff format .
12
+
13
+ format-check:
14
+ uv run ruff check --select I .
15
+ uv run ruff format --check .
16
+
17
+ typecheck:
18
+ uv run ty check .
19
+
20
+ test *args:
21
+ uv run pytest -n auto {{args}}
22
+
23
+ check: format-check typecheck test
24
+
25
+ build:
26
+ uv build
27
+
28
+ release version="":
29
+ if [ -n "{{version}}" ]; then \
30
+ uv run python scripts/release.py --version "{{version}}"; \
31
+ else \
32
+ uv run python scripts/release.py; \
33
+ fi
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anders Brams
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.5
2
+ Name: graphql-typed-python
3
+ Version: 0.1.2
4
+ Summary: Generate typed GraphQL selections, variables, and response dictionaries for Python.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: graphql-core<3.3,>=3.2.6
9
+ Provides-Extra: httpx
10
+ Requires-Dist: httpx>=0.28.1; extra == 'httpx'
11
+ Description-Content-Type: text/markdown
12
+
13
+ # graphql-typed-python
14
+
15
+ Build GraphQL operations with Python dictionary literals and get static types for both the request and the selected response fields. Generation has two passes. The schema supplies completions while you write your operations. Each named operation then supplies the variables and return type for the generated client.
16
+
17
+ ## Quick start
18
+
19
+ Use Python 3.12 or newer. Install the generator in your development environment. Applications using the default HTTP transport also need `httpx`.
20
+
21
+ ```sh
22
+ uv add --dev graphql-typed-python
23
+ uv add httpx
24
+ ```
25
+
26
+ Given a `schema.graphql` file:
27
+
28
+ ```graphql
29
+ type Query { device(serial: String!): Device }
30
+ type Device { id: ID!, name: String!, firmware: String }
31
+ ```
32
+
33
+ Generate the authoring types:
34
+
35
+ ```sh
36
+ uv run graphql-typed generate schema.graphql --out generated
37
+ ```
38
+
39
+ Write `operations.py` alongside the generated package:
40
+
41
+ ```python
42
+ from generated import schema
43
+ from graphql_typed import Operation, var
44
+
45
+ identity: schema.DeviceFields = {"id": True, "name": True}
46
+
47
+
48
+ def operations() -> list[Operation]:
49
+ return [
50
+ schema.query(
51
+ "DeviceBySerial",
52
+ select={
53
+ "device": {
54
+ "args": {"serial": var("serial")},
55
+ "select": identity,
56
+ },
57
+ },
58
+ )
59
+ ]
60
+ ```
61
+
62
+ Generate the client. This command also works on a fresh checkout. The generator evaluates the factory against the newly generated schema types before writing its outputs.
63
+
64
+ ```sh
65
+ uv run graphql-typed generate schema.graphql --out generated --operations operations:operations
66
+ ```
67
+
68
+ Use the same name to execute the operation:
69
+
70
+ ```python
71
+ from generated.client import AsyncClient
72
+
73
+
74
+ async def device_name(client: AsyncClient, serial: str) -> str | None:
75
+ data = await client.query("DeviceBySerial")(variables={"serial": serial})
76
+ if (device := data["device"]) is not None:
77
+ return device["name"]
78
+ return None
79
+ ```
80
+
81
+ Construct a client with `AsyncClient("https://example.test/graphql")`. The sync equivalent is `Client(endpoint).query("DeviceBySerial")(variables={"serial": "R42"})`. Completion follows the selected fields. Accessing `device["firmware"]` in this example is a type error.
82
+
83
+ ## Selections and variables
84
+
85
+ - Use `True` for a leaf field, `args` for field arguments, and `select` for nested fields. Object selections must contain at least one field.
86
+ - Use either a single selection or a list for each field. An alias becomes the key in the result. For example, `"name": [{"alias": "label"}]` yields `device["label"]`. Give distinct aliases to fields with different arguments.
87
+ - Use `var("name")` at an argument, input object field, or list item. The first use determines its GraphQL type. Further uses must have exactly the same type, including nullability and list markers. Custom scalars retain their GraphQL names and use Python `Any`.
88
+ - Input objects are dictionaries and enum values are string literals. Nullable variables can be omitted or set to `None`. A selected nullable response field has a required key whose value can be `None`.
89
+ - Use `schema.mutation(...)` and `client.mutation("Name")(...)` for mutations. Operations without variables are called as `client.query("Name")()`.
90
+ - V1 supports queries and mutations over concrete objects. Subscriptions, directives on selections, and type-specific selections on unions and interfaces are outside its scope.
91
+
92
+ ## Schema sources and output
93
+
94
+ The source can be an SDL file, a local introspection JSON document (raw or wrapped in `data`), or an HTTP(S) GraphQL endpoint. Endpoint generation issues an unauthenticated introspection request. Add `--no-ssl` to disable certificate verification for that request.
95
+
96
+ ```sh
97
+ uv run graphql-typed generate https://example.test/graphql --out generated --operations operations:operations
98
+ ```
99
+
100
+ For programmatic use, import `generate` from `graphql_typed.generator`. It accepts `source`, `out`, and the optional keyword arguments `operations` and `verify_ssl`. The factory reference uses `module:function` and the module must be importable.
101
+
102
+ | Generated module | Contents |
103
+ | --- | --- |
104
+ | `generated.schema` | Authoring types and operation builders. Used during development and generation. |
105
+ | `generated.client` | Sync and async clients with operation-name overloads. |
106
+ | `generated.types` | Input objects, per-operation variables, and response dictionaries. |
107
+ | `generated.transport` | Structural transport protocols and `GraphQLResponseError`. |
108
+
109
+ ## Transports and errors
110
+
111
+ The default transport posts GraphQL JSON using `httpx`. To supply a transport, implement the following method and pass the object to the client. An async transport provides an `async def execute` method with the same parameters.
112
+
113
+ ```python
114
+ from collections.abc import Mapping
115
+ from generated.client import Client
116
+
117
+
118
+ class FakeTransport:
119
+ def execute(
120
+ self, *, document: str, operation_name: str, variables: Mapping[str, object]
121
+ ) -> object:
122
+ return {"data": {"device": {"id": "42", "name": "router"}}}
123
+
124
+
125
+ client = Client(transport=FakeTransport())
126
+ ```
127
+
128
+ A transport returns the decoded GraphQL response envelope. The client returns its `data` on success. When the envelope contains errors, it raises `generated.transport.GraphQLResponseError` with `.errors` and `.data`, including any partial result. Consumers using a custom transport can run the generated client with the Python standard library alone.
129
+
130
+ ## Development
131
+
132
+ ```sh
133
+ uv sync --locked
134
+ prek install
135
+ prek run --all-files
136
+ uv build
137
+ ```
138
+
139
+ Small schemas, operation factories, and `typing.assert_type` examples live in `tests/contract/`. The tests generate clients in temporary packages, check them with `ty`, exercise editor completions via its language server, and execute queries through custom transports and a local GraphQL HTTP server. The TLS test uses the `openssl` command. `just check` runs the same formatting, typing, and test checks used in CI.
140
+
141
+ The release workflow builds and checks distributions on pushes to the `releases` branch and publishes using PyPI trusted publishing. `just release` runs local release checks and pushes the version bump.