Skip to content

Commit b751317

Browse files
authored
Update custom operations documentation with supported argument examples (#8260)
* Update custom operations documentation with newly supported examples * Add supported argument types section for custom operations * Update query name and remove periods * update enum syntax
1 parent 55c50de commit b751317

File tree

1 file changed

+32
-0
lines changed
  • src/pages/[platform]/build-a-backend/data/custom-business-logic

1 file changed

+32
-0
lines changed

src/pages/[platform]/build-a-backend/data/custom-business-logic/index.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,38 @@ safePrint(echoResponse.echo.content);
510510
```
511511

512512
</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+
```
513545

514546
## Async function handlers
515547

0 commit comments

Comments
 (0)