简体   繁体   中英

How to add server side business logic for a AWS amplify GraphQL API?

Following schema can be found similar on AWS docs > Designing your schema . What I couldn't find until now is an example where only ToDo's with the Status PUBLISHED are exposed by the GraphQL API.

type Todo {
  id: ID!
  name: String
  description: String
  status: TodoStatus
}

enum TodoStatus {
  DRAFT
  PUBLISHED
  DELETED
}

All AWS Amplify directives are described here , also @auth where authorization rules for the ToDo model can be defined but this is not what I am looking for. Furthermore I think that functions won't help either in my case, or am I wrong?

Any Idea how I can make ToDo items with Status DRAFT and DELETED not accessible via GraphAPI (serverside, not in the frontend via queries) ?

Respectively is this possible and as easy as it would be with tools like Django and Django Graphene ?

Seems that the way to go is a custom resolver .

Resolvers are what sit between the API endpoint and the database. They decide who can access this data, what data are they looking for, and how much data they are getting.

DynamoDB resolvers are written in Velocity Template Language ( *.vtl ), which is a language that many developers are probably not familiar with and unfortunately the AWS documentation does not supply many code examples.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM