@@ -60,23 +60,12 @@ const schema = a.schema({
60
60
executionDuration: a .float ()
61
61
}),
62
62
63
- Status: a .enum ({
64
- values: [' ACCEPTED' , ' REJECTED' ]
65
- })
66
-
67
63
// 2. Define your query with the return type and, optionally, arguments
68
64
echo: a
69
65
.query ()
70
- // arguments that this query accepts - scalar, custom types, reference to custom types & enums
66
+ // arguments that this query accepts
71
67
.arguments ({
72
- // scalar field
73
- content: a .string (),
74
- // inline custom type
75
- config: a .customType ({
76
- filter: a .string (),
77
- // reference to enum
78
- status: a .ref (' Status' )
79
- }),
68
+ content: a .string ()
80
69
})
81
70
// return type of the query
82
71
.returns (a .ref (' EchoResponse' ))
@@ -521,6 +510,40 @@ safePrint(echoResponse.echo.content);
521
510
```
522
511
523
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 ({
528
+ values: [' ACCEPTED' , ' REJECTED' ]
529
+ }),
530
+
531
+ echo: a
532
+ .query ()
533
+ .arguments ({
534
+ // scalar field
535
+ content: a .string (),
536
+ // inline custom type
537
+ config: a .customType ({
538
+ filter: a .string (),
539
+ // reference to enum
540
+ status: a .ref (' Status' )
541
+ }),
542
+ })
543
+ .returns (a .string ())
544
+ .authorization (allow => [allow .authenticated ()])
545
+ });
546
+ ```
524
547
525
548
## Async function handlers
526
549
0 commit comments