Skip to content

Commit 6059956

Browse files
committed
refactor(codegen): rename --fields to --select for TS SDK consistency
1 parent ceba37c commit 6059956

6 files changed

Lines changed: 41 additions & 41 deletions

File tree

graphql/codegen/src/__tests__/codegen/__snapshots__/cli-generator.test.ts.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ myapp car find-first --where.id.equalTo <value>
321321
### List car records with field selection
322322

323323
\`\`\`bash
324-
myapp car list --fields id,id
324+
myapp car list --select id,id
325325
\`\`\`
326326

327327
### List car records with filtering and ordering
@@ -393,7 +393,7 @@ myapp driver find-first --where.id.equalTo <value>
393393
### List driver records with field selection
394394

395395
\`\`\`bash
396-
myapp driver list --fields id,id
396+
myapp driver list --select id,id
397397
\`\`\`
398398

399399
### List driver records with filtering and ordering
@@ -706,7 +706,7 @@ const fieldSchema: FieldSchema = {
706706
isElectric: "boolean",
707707
createdAt: "string"
708708
};
709-
const usage = "\\ncar <command>\\n\\nCommands:\\n list List car records\\n find-first Find first matching car record\\n get Get a car by ID\\n create Create a new car\\n update Update an existing car\\n delete Delete a car\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
709+
const usage = "\\ncar <command>\\n\\nCommands:\\n list List car records\\n find-first Find first matching car record\\n get Get a car by ID\\n create Create a new car\\n update Update an existing car\\n delete Delete a car\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
710710
export default async (argv: Partial<Record<string, unknown>>, prompter: Inquirerer, _options: CLIOptions) => {
711711
if (argv.help || argv.h) {
712712
console.log(usage);
@@ -1166,7 +1166,7 @@ const fieldSchema: FieldSchema = {
11661166
name: "string",
11671167
licenseNumber: "string"
11681168
};
1169-
const usage = "\\ndriver <command>\\n\\nCommands:\\n list List driver records\\n find-first Find first matching driver record\\n get Get a driver by ID\\n create Create a new driver\\n update Update an existing driver\\n delete Delete a driver\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
1169+
const usage = "\\ndriver <command>\\n\\nCommands:\\n list List driver records\\n find-first Find first matching driver record\\n get Get a driver by ID\\n create Create a new driver\\n update Update an existing driver\\n delete Delete a driver\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
11701170
export default async (argv: Partial<Record<string, unknown>>, prompter: Inquirerer, _options: CLIOptions) => {
11711171
if (argv.help || argv.h) {
11721172
console.log(usage);
@@ -3197,7 +3197,7 @@ const fieldSchema: FieldSchema = {
31973197
email: "string",
31983198
name: "string"
31993199
};
3200-
const usage = "\\nuser <command>\\n\\nCommands:\\n list List user records\\n find-first Find first matching user record\\n get Get a user by ID\\n create Create a new user\\n update Update an existing user\\n delete Delete a user\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
3200+
const usage = "\\nuser <command>\\n\\nCommands:\\n list List user records\\n find-first Find first matching user record\\n get Get a user by ID\\n create Create a new user\\n update Update an existing user\\n delete Delete a user\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
32013201
export default async (argv: Partial<Record<string, unknown>>, prompter: Inquirerer, _options: CLIOptions) => {
32023202
if (argv.help || argv.h) {
32033203
console.log(usage);
@@ -3425,7 +3425,7 @@ const fieldSchema: FieldSchema = {
34253425
id: "uuid",
34263426
role: "string"
34273427
};
3428-
const usage = "\\nmember <command>\\n\\nCommands:\\n list List member records\\n find-first Find first matching member record\\n get Get a member by ID\\n create Create a new member\\n update Update an existing member\\n delete Delete a member\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
3428+
const usage = "\\nmember <command>\\n\\nCommands:\\n list List member records\\n find-first Find first matching member record\\n get Get a member by ID\\n create Create a new member\\n update Update an existing member\\n delete Delete a member\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
34293429
export default async (argv: Partial<Record<string, unknown>>, prompter: Inquirerer, _options: CLIOptions) => {
34303430
if (argv.help || argv.h) {
34313431
console.log(usage);
@@ -3640,7 +3640,7 @@ const fieldSchema: FieldSchema = {
36403640
isElectric: "boolean",
36413641
createdAt: "string"
36423642
};
3643-
const usage = "\\ncar <command>\\n\\nCommands:\\n list List car records\\n find-first Find first matching car record\\n get Get a car by ID\\n create Create a new car\\n update Update an existing car\\n delete Delete a car\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --fields <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
3643+
const usage = "\\ncar <command>\\n\\nCommands:\\n list List car records\\n find-first Find first matching car record\\n get Get a car by ID\\n create Create a new car\\n update Update an existing car\\n delete Delete a car\\n\\nList Options:\\n --limit <n> Max number of records to return (forward pagination)\\n --last <n> Number of records from the end (backward pagination)\\n --after <cursor> Cursor for forward pagination\\n --before <cursor> Cursor for backward pagination\\n --offset <n> Number of records to skip\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)\\n\\nFind-First Options:\\n --select <fields> Comma-separated list of fields to return\\n --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)\\n --condition.<f>.<op> Condition filter (dot-notation)\\n\\n --help, -h Show this help message\\n";
36443644
export default async (argv: Partial<Record<string, unknown>>, prompter: Inquirerer, _options: CLIOptions) => {
36453645
if (argv.help || argv.h) {
36463646
console.log(usage);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export function generateSkills(
427427
},
428428
{
429429
description: `List ${singularName} records with field selection`,
430-
code: [`${toolName} ${kebab} list --fields id,${pk.name}`],
430+
code: [`${toolName} ${kebab} list --select id,${pk.name}`],
431431
},
432432
{
433433
description: `List ${singularName} records with filtering and ordering`,

graphql/codegen/src/core/codegen/cli/table-command-generator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ function buildListHandler(table: Table, vectorFieldNames: string[], targetName?:
572572

573573
/**
574574
* Build a `handleFindFirst` function — CLI equivalent of the TS SDK's findFirst().
575-
* Accepts --fields, --where.<field>.<op>, --condition.<field>.<op> flags.
575+
* Accepts --select, --where.<field>.<op>, --condition.<field>.<op> flags.
576576
* Internally calls findMany with first:1 and returns a single record (or null).
577577
*/
578578
function buildFindFirstHandler(table: Table, targetName?: string, typeRegistry?: TypeRegistry): t.FunctionDeclaration {
@@ -654,7 +654,7 @@ function buildFindFirstHandler(table: Table, targetName?: string, typeRegistry?:
654654
* Build a `handleSearch` function for tables with search-capable fields.
655655
* Extracts the first positional arg as the query string and auto-builds a
656656
* `where` clause that targets all detected search fields (tsvector, BM25,
657-
* trigram, vector embedding). Supports --limit, --offset, --fields, --orderBy.
657+
* trigram, vector embedding). Supports --limit, --offset, --select, --orderBy.
658658
*/
659659
function buildSearchHandler(
660660
table: Table,
@@ -1376,13 +1376,13 @@ export function generateTableCommand(table: Table, options?: TableCommandOptions
13761376
' --after <cursor> Cursor for forward pagination',
13771377
' --before <cursor> Cursor for backward pagination',
13781378
' --offset <n> Number of records to skip',
1379-
' --fields <fields> Comma-separated list of fields to return',
1379+
' --select <fields> Comma-separated list of fields to return',
13801380
' --where.<field>.<op> Filter (dot-notation, e.g. --where.name.equalTo foo)',
13811381
' --condition.<f>.<op> Condition filter (dot-notation)',
13821382
' --orderBy <values> Comma-separated ordering values (e.g. NAME_ASC,CREATED_AT_DESC)',
13831383
'',
13841384
'Find-First Options:',
1385-
' --fields <fields> Comma-separated list of fields to return',
1385+
' --select <fields> Comma-separated list of fields to return',
13861386
' --where.<field>.<op> Filter (dot-notation, e.g. --where.status.equalTo active)',
13871387
' --condition.<f>.<op> Condition filter (dot-notation)',
13881388
'',
@@ -1393,7 +1393,7 @@ export function generateTableCommand(table: Table, options?: TableCommandOptions
13931393
' <query> Search query string (required)',
13941394
' --limit <n> Max number of records to return',
13951395
' --offset <n> Number of records to skip',
1396-
' --fields <fields> Comma-separated list of fields to return',
1396+
' --select <fields> Comma-separated list of fields to return',
13971397
' --orderBy <values> Comma-separated list of ordering values',
13981398
);
13991399
if (hasEmbeddings) {

0 commit comments

Comments
 (0)