-
Notifications
You must be signed in to change notification settings - Fork 9
Add $args symbol support for field arguments in selections
#936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1f0bbd7 to
f3d26cf
Compare
| mutate(graphQL: string, variables?: Record<string, any>): Promise<any>; | ||
| transaction<T>(callback: (transaction: GadgetTransaction) => Promise<T>): Promise<T>; | ||
| internal: InternalModelManagerNamespace; | ||
| $args: typeof $args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4ea6522 to
d7d5ecc
Compare
packages/core/src/AnyClient.ts
Outdated
| internal: InternalModelManagerNamespace; | ||
| [$modelRelationships]?: { [modelName: string]: { [apiIdentifier: string]: { type: string; model: string } } }; | ||
| [$coreImplementation]?: AnyCoreImplementation; | ||
| [$args]?: typeof $args; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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
d7d5ecc to
c2cd668
Compare
infiton
left a comment
There was a problem hiding this 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
b263412 to
a3aba9c
Compare
fc40c8d to
7f0b304
Compare
7f0b304 to
fa4aa71
Compare
Introduces a
$argssymbol key for passing GraphQL field arguments within field selections.Changes:
$argssymbol andFieldArgstype toFieldSelectioninterfaceInnerSelecttype to exclude$argsfrom selection results$argsis properly excluded from selected typesExample usage:
PR Checklist