Skip to content

Conversation

@shardulbee
Copy link
Contributor

Introduces a $args symbol key for passing GraphQL field arguments within field selections.

Changes:

  • Added $args symbol and FieldArgs type to FieldSelection interface
  • Updated InnerSelect type to exclude $args from selection results
  • Added type tests to verify $args is properly excluded from selected types

Example usage:

{
  comments: {
    [$args]: { after: "cursor", first: 10 },
    body: true
  }
}

PR Checklist

  • Important or complicated code is tested
  • Any user facing changes are documented in the Gadget-side changelog
  • Any immediate changes are slated for release in Gadget via a generated package dependency bump
  • Versions within this monorepo are matching and there's a valid upgrade path

mutate(graphQL: string, variables?: Record<string, any>): Promise<any>;
transaction<T>(callback: (transaction: GadgetTransaction) => Promise<T>): Promise<T>;
internal: InternalModelManagerNamespace;
$args: typeof $args;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@infiton I think I remember you and @airhorns saying that you wanted to make the $args symbol available as part of api ?

@shardulbee shardulbee force-pushed the push-uuwwlkkvwzlu branch 2 times, most recently from 4ea6522 to d7d5ecc Compare December 4, 2025 20:50
internal: InternalModelManagerNamespace;
[$modelRelationships]?: { [modelName: string]: { [apiIdentifier: string]: { type: string; model: string } } };
[$coreImplementation]?: AnyCoreImplementation;
[$args]?: typeof $args;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think we don't need this on the AnyClient type; I don't think we'd want the key to be the symbol anyways

I think we'll either re-export this symbol from the generated client package or add it as a string property so you could do

await api.myVec.findFirst({select: {
  vecL2DistanceTo: {
    [api.$args]: { vector: [1,2,3] }
  }
}});

or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that what this line enables?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite as the property key would be the symbol so to access it you'd need to so

api[Symbol.for("gadget/fieldArgs")]

you could do

export interface AnyClient {
  $args: symbol
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah this was a dumb mistake, sorry nice catch. will fix

Copy link
Contributor

@infiton infiton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good; before merging though let me show you how you can get some confidence it'll work nice in the monorepo

@shardulbee shardulbee force-pushed the push-uuwwlkkvwzlu branch 3 times, most recently from b263412 to a3aba9c Compare December 8, 2025 21:33
@shardulbee shardulbee force-pushed the push-uuwwlkkvwzlu branch 2 times, most recently from fc40c8d to 7f0b304 Compare December 10, 2025 21:21
@shardulbee shardulbee merged commit 5a8048c into main Dec 11, 2025
12 checks passed
@shardulbee shardulbee deleted the push-uuwwlkkvwzlu branch December 11, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants