File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/pages/[platform]/build-a-backend/data/custom-business-logic Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -510,6 +510,38 @@ safePrint(echoResponse.echo.content);
510
510
```
511
511
512
512
</InlineFilter >
513
+ ## Supported Argument Types in Custom Operations
514
+
515
+ Custom operations can accept different types of arguments. Understanding these options helps define flexible and well-structured APIs.
516
+
517
+ ### Defining Arguments in Custom Operations
518
+
519
+ When defining a custom operation, you can specify arguments using different types:
520
+
521
+ - ** Scalar Fields** : Basic types such as ` string ` , ` integer ` , ` float ` , etc
522
+ - ** Custom Types** : Define inline ` customType `
523
+ - ** Reference Types** : Use ` a.ref() ` to reference enums and custom types
524
+
525
+ ``` ts title="amplify/data/resource.ts"
526
+ const schema = a .schema ({
527
+ Status: a .enum ([' ACCEPTED' , ' REJECTED' ]),
528
+
529
+ getPost: a
530
+ .query ()
531
+ .arguments ({
532
+ // scalar field
533
+ content: a .string (),
534
+ // inline custom type
535
+ config: a .customType ({
536
+ filter: a .string (),
537
+ // reference to enum
538
+ status: a .ref (' Status' )
539
+ }),
540
+ })
541
+ .returns (a .string ())
542
+ .authorization (allow => [allow .authenticated ()])
543
+ });
544
+ ```
513
545
514
546
## Async function handlers
515
547
You can’t perform that action at this time.
0 commit comments