Skip to content

Commit 629c736

Browse files
committed
fix: use .execute().unwrap() chaining pattern in generated AGENTS.md
1 parent 017e713 commit 629c736

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

graphql/codegen/src/core/codegen/orm/docs-generator.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,19 @@ export function generateOrmAgentsDocs(
201201
lines.push('// WRONG — errors are silently lost:');
202202
lines.push('try { const r = await db.model.findMany({...}).execute(); } catch (e) { /* never runs */ }');
203203
lines.push('');
204-
lines.push('// RIGHT — .unwrap() throws GraphQLRequestError on failure:');
205-
lines.push('const data = await db.model.findMany({...}).unwrap();');
204+
lines.push('// RIGHT — .execute().unwrap() throws GraphQLRequestError on failure:');
205+
lines.push('const data = await db.model.findMany({...}).execute().unwrap();');
206206
lines.push('');
207207
lines.push('// RIGHT — check .ok for control flow:');
208208
lines.push('const result = await db.model.findMany({...}).execute();');
209209
lines.push('if (!result.ok) { console.error(result.errors); return; }');
210210
lines.push('return result.data;');
211211
lines.push('```');
212212
lines.push('');
213-
lines.push('Available helpers on QueryBuilder (call **instead of** `.execute()`):');
214-
lines.push('- `.unwrap()` — throws on error, returns typed data');
215-
lines.push('- `.unwrapOr(default)` — returns default value on error');
216-
lines.push('- `.unwrapOrElse(fn)` — calls callback with errors on failure');
213+
lines.push('Available helpers (chain after `.execute()`):');
214+
lines.push('- `.execute().unwrap()` — throws on error, returns typed data');
215+
lines.push('- `.execute().unwrapOr(default)` — returns default value on error');
216+
lines.push('- `.execute().unwrapOrElse(fn)` — calls callback with errors on failure');
217217
lines.push('');
218218

219219
lines.push('## Resources');
@@ -227,7 +227,7 @@ export function generateOrmAgentsDocs(
227227
lines.push('');
228228
lines.push('- Access models via `db.<ModelName>` (e.g. `db.User`)');
229229
lines.push('- CRUD methods: `findMany`, `findOne`, `create`, `update`, `delete`');
230-
lines.push('- Call `.unwrap()` to run and throw on error, or `.execute()` for discriminated union result');
230+
lines.push('- Chain `.execute().unwrap()` to run and throw on error, or `.execute()` alone for discriminated union result');
231231
lines.push('- Custom operations via `db.query.<name>` or `db.mutation.<name>`');
232232
lines.push('');
233233

0 commit comments

Comments
 (0)