doc/md: update grpc tutorial for List and BatchCreate methods (#2518)

This commit is contained in:
Jeremy Maxey-Vesperman
2022-07-31 02:12:15 -04:00
committed by GitHub
parent 9673a4d506
commit 3f04b0fe6e
2 changed files with 19 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ id: grpc-service-generation-options
title: Configuring Service Method Generation
sidebar_label: Service Generation Options
---
By default, entproto will generate CRUD service methods for an `ent.Schema` annotated with `ent.Service()`. Method generation can be customized by including the argument `entproto.Methods()` in the `entproto.Service()` annotation. `entproto.Methods()` accepts bit flags to determine what service methods should be generated. The flags include:
By default, entproto will generate a number of service methods for an `ent.Schema` annotated with `ent.Service()`. Method generation can be customized by including the argument `entproto.Methods()` in the `entproto.Service()` annotation. `entproto.Methods()` accepts bit flags to determine what service methods should be generated. The flags include:
```go
// Generates a Create gRPC service method for the entproto.Service.
entproto.MethodCreate
@@ -17,6 +17,12 @@ entproto.MethodUpdate
// Generates a Delete gRPC service method for the entproto.Service.
entproto.MethodDelete
// Generates a List gRPC service method for the entproto.Service.
entproto.MethodList
// Generates a Batch Create gRPC service method for the entproto.Service.
entproto.MethodBatchCreate
// Generates all service methods for the entproto.Service.
// This is the same behavior as not including entproto.Methods.
entproto.MethodAll
@@ -30,7 +36,7 @@ func (User) Annotations() []schema.Annotation {
return []schema.Annotation{
entproto.Message(),
entproto.Service(
entproto.Methods(entproto.MethodCreate | entproto.MethodGet),
entproto.Methods(entproto.MethodCreate | entproto.MethodGet | entproto.MethodList | entproto.MethodBatchCreate),
),
}
}
@@ -42,6 +48,10 @@ service UserService {
rpc Create ( CreateUserRequest ) returns ( User );
rpc Get ( GetUserRequest ) returns ( User );
rpc List ( ListUserRequest ) returns ( ListUserResponse );
rpc BatchCreate ( BatchCreateUsersRequest ) returns ( BatchCreateUsersResponse );
}
```