ivome / graphql-relay-php

A library to help construct a graphql-php server supporting react-relay.
BSD 3-Clause "New" or "Revised" License
271 stars 27 forks source link

edge's in mutation payload #12

Closed tim-field closed 7 years ago

tim-field commented 7 years ago

Relay range add wants to have an edge as part of the payload.

I'm wondering how this feature could be implemented. I've tried to work out how other libraries are doing it, but I'm a little lost currently. Keen to hear what your think.

tim-field commented 7 years ago

Oh ok I guess its going to be something to do with Relay::cursorForObjectInConnection :thinking: :hammer_and_wrench:

ivome commented 7 years ago

You would have to use the edge type of the connection as the field type of the mutation payload. We implemented that via #5, which makes it possible to create and reuse the edge type. Then you can simply create the edge value in your code and return it in the mutation. The cursor values depend on the pagination and cursor implementation of your data layer. You might be able to reuse the helper functions of this library.