-
Notifications
You must be signed in to change notification settings - Fork 18
feat: allow customtypes ref in arguments/main #497
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
Changes from 20 commits
e7f97fa
0e0561e
1a54cde
ecf2ec2
a0872b9
2f7e948
45074a3
3517643
2e81a9d
c54ed9b
a7dd990
cc50e20
fff0b5d
f4b9171
949e6ee
cdb02d1
2f8c281
6b82830
f1b8e0e
acaa7d4
0f19e89
832a436
3b32405
8ddcf13
a4c040e
59c34ba
1310383
bb7b4f2
5b04623
29d3596
cb5c732
12cf372
e817980
e644a53
69f1254
bd835e3
0f9992e
ed6dd7c
d7682c8
36afaf4
7bd9d1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@aws-amplify/data-schema": minor | ||
| --- | ||
|
|
||
| Allow CustomType and RefType in arguments for custom operations |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,8 @@ import type { AppSyncResolverHandler } from 'aws-lambda'; | |
| import type { CustomType } from '../../CustomType'; | ||
| import type { FieldTypesOfCustomType } from '../../MappedTypes/ResolveSchema'; | ||
| import type { ResolveRef } from '../utilities/ResolveRef'; | ||
| import type { EnumType } from '../../EnumType'; | ||
| import { ClientSchemaProperty } from './ClientSchemaProperty'; | ||
| import type { ResolveFields } from '../utilities'; | ||
|
|
||
| type CustomOperationSubType<Op extends CustomOperationParamShape> = | ||
| `custom${Op['typeName']}`; | ||
|
|
@@ -38,7 +38,7 @@ export interface ClientCustomOperation< | |
| * ``` | ||
| */ | ||
| functionHandler: AppSyncResolverHandler< | ||
| CustomOpArguments<Op>, | ||
| CustomOpArguments<Op, RefBag>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's resolved now with Expand in ResolveFields, ensuring the input fields are properly unwrapped.
This comment was marked as resolved.
Sorry, something went wrong. |
||
| // If the final handler is an async function, the Schema['fieldname']['functionhandler'] | ||
| // should have a return type of `void`. This only applies to `functionHandler` and not | ||
| // `returnType` because `returnType` determines the type returned by the mutation / query | ||
|
|
@@ -60,7 +60,7 @@ export interface ClientCustomOperation< | |
| * } | ||
| * ``` | ||
| */ | ||
| args: CustomOpArguments<Op>; | ||
| args: CustomOpArguments<Op, RefBag>; | ||
|
|
||
| /** | ||
| * The return type expected by a lambda function handler. | ||
|
|
@@ -84,19 +84,18 @@ export interface ClientCustomOperation< | |
|
|
||
| /** | ||
| * Digs out custom operation arguments, mapped to the intended graphql types. | ||
| * using the existing ResolveFields utility type. This handles: | ||
| * - Basic scalar fields | ||
| * - Enum types | ||
| * - Custom types (including nested structures) | ||
| * - Reference types | ||
| */ | ||
| type CustomOpArguments<Shape extends CustomOperationParamShape> = | ||
| Shape['arguments'] extends null | ||
| ? never | ||
| : ResolveFieldRequirements<{ | ||
| [FieldName in keyof Shape['arguments']]: Shape['arguments'][FieldName] extends BaseModelField< | ||
| infer R | ||
| > | ||
| ? R | ||
| : Shape['arguments'][FieldName] extends EnumType<infer Values> | ||
| ? Values[number] | null | ||
| : never; | ||
| }>; | ||
| type CustomOpArguments< | ||
| Shape extends CustomOperationParamShape, | ||
| RefBag extends Record<string, any> = any, | ||
| > = Shape['arguments'] extends null | ||
| ? never | ||
| : ResolveFields<RefBag, Shape['arguments']>; | ||
|
|
||
| /** | ||
| * Removes `null | undefined` from the return type if the operation is a subscription, | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.