2016-11-24 2 views
0

를 범하지 않지만 돌연변이 (나는/성공에서 어떤 기록을 얻을 콜백을 실패하지 않는) 커밋 것 같다 결코 아니다 나는 내 Graph 구현의 기능에있는 console.log에서 아무것도 얻지 못하고있다.Relay.Store.commitUpdate 결코 내가 최근 <strong>가 기본</strong> 응용 프로그램 반응 내에서 <strong>릴레이</strong>를 사용하기 시작했다

내 응용 프로그램의 루트 구성 요소에 다음 코드가 있습니다. 사실 내 앱에 업데이트 된 이름이 표시 될 필요는 없습니다. 단지 DB를 업데이트하기위한 것입니다.

class App extends Component { 
    componentDidMount() { 
     Relay.Store.commitUpdate(new DogMutation({name: 'Stack'}, { 
      onSuccess:() => console.log("success"), 
      onFailure: (transaction) => console.error(transaction) 
     )) 
    } 
} 

돌연변이 클래스는 다음과 같습니다

GraphQL 측 돌연변이 코드는 다음과 같습니다
export default class DogMutation extends Mutation { 
    getFatQuery() { 
     return Relay.QL` 
      fragment on Dog { 
       name 
      } 
     ` 
    } 

    getMutation() { 
     return Relay.QL`mutation {renameDog}` 
    } 

    getVariables() { 
     return { 
      name: this.props.name 
     } 
    } 

    getConfigs() { 
     return [] 
    } 
} 

: 나는 Relay.Store.commitUpdate()를 호출 할 때

export const renameDog = { 
    type: Dog, 
    description: `Rename a dog.`, 
    args: { 
     input: { 
      type: new GraphQLInputObjectType({ 
       name: `DogInput`, 
       fields: { 
        name: { 
         type: GraphQLString, 
        } 
       } 
      }) 
     } 
    }, 
    async resolve (obj, args) { 
     console.log(args) <- Which never outputs 
    } 
} 

, 내가 얻을 :

RelayMutationQueue.js:390 Optimistic query for `renameDog` 
RelayMutationQueue.js:454 Mutation query for `renameDog` 
내 React 네이티브 크롬 디버거에서 10

내 코드에 문제가 있습니까? 내가 읽은 여러 기사 중에서 뭔가를 놓칠 수 있습니까? 내 직감은 을 어딘가에서 생성하여 props으로 전달하는 대신 직접 사용하고 있지만 이것이 글로벌 인스턴스임을 이해하고 있습니다.

답변

0

그래서이 문제는 나를 까지 도와 주실 때까지 찾아 주셨습니다.

콜백은 돌연변이의 초기화에 속하지 않으므로 호출되지 않았습니다. commitUpdate 함수의 두 번째 인수입니다.

0

그래서 graphql-relaymutationWithClientMutationId 함수를 사용했는데 실제로 메시지를 커밋 한 것으로 보이지만 여전히 돌연변이에서 콜백이 없습니다.

+0

안녕하세요, Chrome 디버거의 '네트워크'탭에 무엇이 출력됩니까? 요청을 보냈습니까? – whitep4nther

+0

또한 Container와 RootContainer에서 애플리케이션을 랩핑하고 대신'this.props.relay'를 호출 할 수 있습니까? – whitep4nther

+0

@ whitep4nther'this.props.relay.commitUpdate ({name : 'foo'})'를 해보려고했는데, GraphQL을 치고 있지만 콜백이나 아무 것도 없습니다. –

관련 문제