feat: refactor documentation AR-8#446
Conversation
Split the flat docs/ files into guides/reference/plugins/community sections with proper sidebar categories, add missing guide pages (schema sources, subscriptions, file uploads, custom scalars, extending types, multiple clients, OpenTelemetry, async vs sync, schema generation), and slim README.md down to a feature overview that links out to the new docs site instead of duplicating content.
…gration Relative links inside docs/ still pointed at the old docs/... paths, em dashes rendered inconsistently, and a few pages were missing recently added settings (remote_schema_http_client_path, introspection_*, opentelemetry-api dependency).
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
I wasn't able to set this int reference for the readme, so here's a copy-paste
There was a problem hiding this comment.
Do we need this file?
There was a problem hiding this comment.
leave it for now
Co-authored-by: Aleksander Spyra <aleksander.spyra@mirumee.com>
- schema-sources: document directory extension behavior; reframe schema_paths around combining multiple files (installed packages as secondary use case) - using-generated-client: add basic init example, drop redundant headers heading, move context-manager section before configuration, split advanced HTTP config into httpx vs custom-client sections, fix non-httpx client claims - subscriptions: drop redundant client-configuration link - extending-types: clarify files_to_include is required for relative mixin imports - opentelemetry: link opentelemetry-api to PyPI - async-vs-sync: drop duplicated setting bullet and sections repeating the client guide - schema-generation: bulletize schema-source options, link process_schema hook - custom-operation-builder: fold Enabling into intro, rename example sections - configuration: restore original remote_schema_http_client_path description - README: link Contributing directly to CONTRIBUTING.md
The use_alias_generator branch predates the docs-site refactor (#446), so it added these two guides as flat docs/07 and docs/08 pages and linked them from a monolithic README. Move them under docs/02-guides/ to match the current structure and repoint the config-reference links. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The use_alias_generator branch predates the docs-site refactor (#446), so it added these two guides as flat docs/07 and docs/08 pages and linked them from a monolithic README. Move them under docs/02-guides/ to match the current structure and repoint the config-reference links.
* feat: add use_alias_generator setting
* fix: don't silently ship wrong aliases or unformatted code
* fix: keep fragment forward references resolvable in operation modules
A generated client whose operation spreads a fragment could not be imported
on Python 3.10, with or without `defer_model_build`:
PydanticUndefinedAnnotation: name 'UserFieldsFriends' is not defined
A fragment names its nested selections by forward reference, and an operation
that spreads it subclasses the fragment class from another module:
# fragments.py
class UserFields(BaseModel):
friends: list["UserFieldsFriends"]
# list_users.py
class ListUsersUsers(UserFields):
pass
Pydantic resolves the annotations a subclass inherits against the subclass's
own module, and `UserFieldsFriends` lives in `fragments`. On 3.11+ the
inherited `ForwardRef` evaluation is reused and this happens to work; on 3.10
it is re-evaluated and fails. `requires-python` is `>= 3.10` and the default
hatch environment pins 3.10, so this failed on the version CI runs.
With `defer_model_build` the same shape failed on every supported version,
because dropping the eager `model_rebuild()` calls removes the only thing
that ever resolved those references.
Emit the names the mixin bases need into the module that has to resolve them:
from .fragments import (
UserFields,
UserFieldsFriends, # noqa: F401
)
The `noqa` is required because the name appears only inside an inherited
annotation. Keeping the build deferred rather than restoring the eager
fragment rebuilds preserves the whole import-time win - `defer_model_build`
now measures 1.79x faster to import on a 1448-type schema, against 1.74x
before, because no fragment models are built at import.
Add `ForwardRefNamesVisitor` and `collect_class_forward_ref_names()` in
`codegen.py`; `_map_fragment_forward_refs()` and `_mixin_forward_ref_import()`
in `package.py`. `ast.unparse` drops comments, so the line is injected as raw
source through the new `prepend_code` argument of `_queue_module`. Clients
with no fragment mixin are byte-for-byte unchanged.
The suite never caught this because every `expected_client` fixture is inert:
the tests diff generated source and never import it. Add two tests that
import a generated package and validate a payload, one per path. Both fail
only on Python 3.10, which the default hatch environment provides.
* docs: record graphql-core dependency and the two import-performance settings
`enable_custom_operations` makes the generated `base_operation.py` and
`client.py` import graphql-core to build and print a query AST at runtime, so
the generated package needs it alongside pydantic and httpx. It was missing
from "Generated code dependencies" and costs roughly 25 ms of import.
`defer_model_build` and `use_alias_generator` were documented in the README
but absent from the optional-settings list in `docs/02-configuration.md`,
where every other setting lives.
Also describe the `# noqa: F401` fragment import that generated operation
modules now carry, so it does not read as a code-generation bug to anyone
running a linter over the output.
* test: cover alias_generator in the multipart_uploads=false base-model test
Now that use_alias_generator exists, extend the no-upload base-model config test
to also enable it and assert alias_generator=to_camel lands on the generated
BaseModel - exercising the base-model source-path detection for all three
config rewrites in the uploads-disabled path.
* build: require pydantic >=2.8 for use_alias_generator
`use_alias_generator` sets `alias_generator=to_camel` and omits the explicit
`Field(alias=...)` for fields whose GraphQL name `to_camel` can reconstruct.
`to_camel`'s case handling was fixed in pydantic 2.8 (pydantic/pydantic#9561);
on earlier versions it could mangle names, so the generated package would
rebuild the wrong aliases. Raise the floor to 2.8 to match.
* docs: tighten the to_camel / pydantic 2.8 floor comments
* docs: move import-performance and fragments docs out of README
* fix: don't let the BaseModel config rewrite go missing unnoticed
* docs: drop the defer_model_build aside from the fragments page
* test: consolidate the rewrite_base_model config tests
* docs: place the import-performance and fragments guides in the docs site
The use_alias_generator branch predates the docs-site refactor (#446), so it
added these two guides as flat docs/07 and docs/08 pages and linked them from a
monolithic README. Move them under docs/02-guides/ to match the current
structure and repoint the config-reference links.
* fix: satisfy ty 0.0.62 in extract_operations and shorter_results
ty 0.0.62 (stricter than the version CI ran previously) flags two spots in
existing contrib plugins: the `ast.Constant.value` union widens the list
passed to `sorted()` past `SupportsRichComparison`, and `ImportFrom.module`
is `str | None` so indexing the `dict[str, set]` of extended imports with it
is rejected. Narrow the constant to `str` and bind/guard the module name.
No behaviour change.
Restructures the docs from a flat, README-derived layout into a categorized Docusaurus site, and slims README.md into a landing page. Content was split out of the README, then expanded and corrected against the source code - several settings and behaviours were missing or stale.
New docs/ structure: