How to manage cursors and sorting in Relay?

后端 未结 2 708
温柔的废话
温柔的废话 2021-02-09 07:18

We have a graphql server (not written in javascript) serving a paginated list of objects. We\'re trying to conform to the relay specification, but we\'ve hit an interesting case

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-09 08:11

    Yes, the cursor should contain enough information in it to enable fetching the next page from that point onwards (including constraints such as sorting and filtering), but whether/how you do this is up to you as it is implementation-specific.

    As for mutations, in your getConfigs() implementation you can specify rangeBehaviors on a per-call basis. So, if you have a sorted view, you might choose to append or prepend depending on the sort order. This behavior specifies what Relay will do on the client-side to update its store. It's still your responsibility to ensure that the code your GraphQL server receives all the information it needs (via input variables) to correctly perform the actual mutation.

提交回复
热议问题