relayjs - Client-side mutation with RANGE_ADD type doesn't include edge inside request payload -
i'm trying create new object using client-side mutation described below:
import relay 'react-relay' export default class createthememutation extends relay.mutation { static fragments = { admin: () => relay.ql`fragment on admin { id }`, }; getmutation() { return relay.ql`mutation { createtheme }` } getfatquery() { return relay.ql` fragment on createthemepayload { admin { themes } themeedge } ` } getvariables() { return { name: this.props.name, } } getconfigs() { return [{ type: 'range_add', parentname: 'admin', parentid: this.props.admin.id, connectionname: 'themes', edgename: 'themeedge', rangebehaviors: { '': 'append', }, }] } } root query field admin quite similar viewer shouldn't problem. problem haven't found themeedge (which believe should present) within request payload (admin { themes } there though):
query: "mutation createthememutation($input_0:createthemeinput!){createtheme(input:$input_0){clientmutationid,...f3}} fragment f0 on admin{id} fragment f1 on admin{id,...f0} fragment f2 on admin{_themes2gcwom:themes(first:20,query:""){count,pageinfo{hasnextpage,haspreviouspage,startcursor,endcursor},edges{node{id,name,createdat},cursor}},id,...f1} fragment f3 on createthemepayload{admin{id,...f0,id,...f2}}" variables: {input_0: {name: "test", clientmutationid: "0"}} as result outputfields.themeedge.resolve inside server-side mutation never called , see message:
warning: writerelayupdatepayload(): expected response payload include newly created edge `themeedge` , `node` field. did forget update `range_add` mutation config? i've seen similar issue on github. required_children isn't case because application has requested themes connection already. missing obvious? should paste more info? thanks.
react-relay version: 0.6.1
i ran same issue , solved making sure equivalent of themeedge existed edge in schema. if grep schema themeedge, object exist?
for reference, here's edge definition tailored you:
{ "name":"themeedge", "description":null, "args":[], "type":{ "kind":"non_null", "name":null, "oftype":{ "kind":"object", "name":"themeedge", "oftype":null } }, "isdeprecated":false, "deprecationreason":null } and
{ "kind":"object", "name":"themeedge", "description":"an edge in connection.", "fields":[{ "name":"node", "description":"the item @ end of edge.", "args":[], "type":{ "kind":"non_null", "name":null, "oftype":{ "kind":"object", "name":"theme", "oftype":null } }, "isdeprecated":false, "deprecationreason":null } also note rangebehaviors must exactly match query use retrieve parent object. can specify multiple queries follows, shows syntax when query contains multiple variables:
{ type: 'range_add', parentname: 'admin', parentid: this.props.admin.id, connectionname: 'themes', edgename: 'themeedge', rangebehaviors: { '': 'append', 'first(1).id($adminid)': 'append', }, }
Comments
Post a Comment