作者:Joanna阿咪个_995 | 来源:互联网 | 2023-08-22 20:21
how to make authorzation layer when i generated a graphql server.
i think we need a event call before call each query/mutation.
for:
- authorization layer (Before* event)
- access log (After* event)
- common control logic
its like:
1 2 3 4 5 6 7 8 9
| go
type Event interface{
BeforeQuery(ctx context.Context)
BeforeEachQuery(ctx context.Context,opName string,opParams map[string]interface{})
BeforeEachMutation(ctx context.Context,opName string,opParams map[string]interface{})
AfterQuery(ctx context.Context)
AfterEachQuery(ctx context.Context,opName string,opParams map[string]interface{},output interface{})
AfterEachMutation(ctx context.Context,opName string,opParams map[string]interface{},output interface{})
} |
该提问来源于开源项目:99designs/gqlgen
Closed in favour of https://github.com/vektah/gqlgen/issues/156