How to get RelayJS to understand that a response from GraphQL is an array of items, not just a single item

前端 未结 1 1112
眼角桃花
眼角桃花 2020-12-30 12:51

I have a GraphQL server running with a schema roughly like this:

type Card {
  id: String!
  name: String
}

type Query {
  card(name: String!): Card
  cards         


        
相关标签:
1条回答
  • 2020-12-30 13:44

    You probably want a @relay(plural: true) directive on your cards query fragment. There is an example of a plural field in action in the Star Wars example in the Relay repo.

    If you care about pagination, though, you probably want a connection instead of a plural field. Connections are described in the Relay docs and implemented in graphql-relay-js.

    0 讨论(0)
提交回复
热议问题