2017-09-15 4 views
1

나는 컬렉션과 새로운 아이템을 추가하기위한 돌연변이가있다. 성공적인 돌연변이 이후 UI를 업데이트하기 위해 Relay Modern을 얻을 수 없었습니다.Relay Modern Mutations, RANGE_ADD/Append

나는 다음과 PaginationContainer 설치 query:

{ 
    query: graphql` 
     fragment ContactsList_query on WPQuery { 
      id 
      contacts: posts(
       first: $count, 
       after: $cursor 
       post_type: $postType, 
       order: $order, 
       category_name: $categoryName 
     ) @connection(key: "ContactsList_contacts") { 
      edges { 
       node { 
       id 
       ...ContactListItem_contact 
       } 
      } 
      pageInfo { 
       hasNextPage 
       endCursor 
      } 
      } 
     } 
    ` 
    }, 

소품 제대로 가져옵니다 있어요. 나는이 목록에 연락처를 추가 할 돌연변이를 얻었습니다. 구성 RANGE_ADD 또는 updater: 콜백 기술이 전혀 작동하지 않습니다.

나는 그렇게

onSave = (fields) => { 
    insertPost(
     fields.toJS(), 
     this.props.query.id, 
     this.props.relay.environment 
    ); 
    } 

없음 오류, 그냥 아무것도 업데이트처럼이 돌연변이를 유발하고있다.

const mutation = graphql` 
    mutation InsertPostMutation(
    $data: InsertPostInput! 
) { 
    insert_post(input: $data) { 
     wp_query { 
     id 
     } 
     postEdge { 
     node { 
      id 
      title 
     } 
     } 
    } 
    } 
`; 

export default function insertPost(data, id, environment) { 
    const variables = { 
    data, 
    }; 

    commitMutation(
    environment, 
    { 
     mutation, 
     variables, 
     onCompleted: (response, errors) => { 
     console.log('Response received from server.') 
     }, 
     onError: err => console.error(err), 
     configs: [{ 
     type: 'RANGE_ADD', 
     parentID: id, 
     connectionInfo: [{ 
      key: 'ContactsList_contacts', 
      rangeBehavior: 'append', 
     }], 
     edgeName: 'postEdge' 
     }], 
     // updater: (store) => { 
     // // const inspector = new RecordSourceInspector(store) 
     // const payload = store.getRootField('insert_post') 
     // const newEdge = payload.getLinkedRecord('postEdge') 
     // const proxy = store.get(id) 
     // // Conn is always undefined here 
     // const conn = ConnectionHandler.getConnection(proxy, 'ContactsList_contacts') 
     // ConnectionHandler.insertEdgeAfter(conn, newEdge) 
     // } 
    }, 
); 
} 

답변