Skip to content

Commit 650fb51

Browse files
committed
Add port rule
1 parent 80a5059 commit 650fb51

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

.cursor/rules/sdk-port.mdc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ Turms config is in `graphql.config.yaml` at the package root.
5353
- The top-level `__init__.py` re-exports the public API. Keep it updated when adding new modules.
5454
- Port one folder/feature at a time. Don't get distracted by issues in files not currently being ported.
5555

56+
### Typed strings (Id, Cursor, Httpql)
57+
58+
Use subclasses of `str` in `types/strings.py` to distinguish IDs, cursors, and HTTPQL in the type system without changing runtime behaviour (they are plain strings; JSON and Pydantic work as for `str`).
59+
60+
- **Output types:** Use `Id`, `Cursor`, or `Httpql` on public dataclass fields and return types (e.g. `FilterPreset.id: Id`, `PageInfo.start_cursor: Cursor | None`, `FilterPreset.clause: Httpql`). In the convert layer, wrap values from GraphQL (e.g. `id=Id(node.id)`, `clause=Httpql(node.clause)`).
61+
- **Input types:** Use the `*Like` aliases so callers can pass either the typed class or a plain `str`: `IdLike = Id | str`, `CursorLike = Cursor | str`, `HttpqlLike = Httpql | str`. Annotate SDK method parameters and option dataclass fields with these (e.g. `id: IdLike`, `id: IdLike | None` for optional). Do not use raw `Id | str` in signatures; use `IdLike` (and `CursorLike` / `HttpqlLike`) for brevity and consistency.
62+
5663
### High-level SDKs (`sdks/*.py`)
5764

5865
- High-level SDKs should:

0 commit comments

Comments
 (0)