Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

amazon web services - AWS amplify DynamoDB Graph QL filter by book title and author name

AWS amplify DynamoDB Graph QL filter by book title and author name

I want to search for books by book title and author name but my schema allows me to search books by book title and author ID, not author name how I can achieve this.

Following is my graphql schema

type Author
@model(subscriptions: null)
@auth(
  rules: [#allow admins to create, update and delete books {
      allow: groups,
      groups: ["owner"]
    }#
    allow all authenticated users to view books {
      allow: private,
      operations: [read]
    }
  ]
)
@key(name: "authorByCreatedAt", fields: ["isDeleted", "createdAt"], queryField: "authorByCreatedAt") {
  id: ID!
    name: String!
    description: String!
    status: Boolean!
    createdAt: String!
    image: String!
    isDeleted: Int!
    books: [Book] @connection(keyName: "byAuthor", fields: ["id"])
}

type Book
@model(subscriptions: null)
@auth(
  rules: [#allow admins to create, update and delete books {
      allow: groups,
      groups: ["owner"]
    }#
    allow all authenticated users to view books {
      allow: private,
      operations: [read]
    }
  ]
)
@key(name: "bookByCreatedAt", fields: ["isDeleted", "createdAt"], queryField: "bookByCreatedAt")
@key(name: "byAuthor", fields: ["authorId"]) {
  id: ID!
    title: String!
    description: String!
    image: String!
    age: Int!
    region: String!
    isbn: String
  narrator: String
  status: Boolean!
    createdAt: String!
    isDeleted: Int!
    book: String!
    bookType: BookType!
    authorId: ID!
    authors: Author @connection(fields: ["authorId"])
}

enum BookType {
  AUDIO
  EPUB
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...