react-apollo
변수를 쿼리 구성 요소 소품을 변환 할 수있는 기능을 제공합니다. 같은react-apollo - 래핑 된 구성 요소에서 쿼리 변수를 설정하는 방법?</p> <pre><code><MyComponentWithData propsForQueryVariables={...} /> </code></pre> <p>하지만 포장 구성 요소에서 변수 쿼리를 시작해야합니다
뭔가 :
query getItems($filter: JSON!) {
items(filter: $filter) {
id
name
}
}
filter
이 Null을 허용하지 입니다
class MyComponent extends React.Component {
//...
onReady() {
// should be first request to server
this.props.refetch({
// variables here
})
}
onFilterChanged() {
this.props.refetch({
// new variables here
})
}
}
const MyComponentWithData = graphql(QUERY, {
options: {
waitUntilComponentStartQuery: true
// pollInterval:...
},
props({ data: { items, refetch } }) {
return {
items: items,
refetch: refetch
};
}
})(MyComponent);
UPDATE MyComponent
에 대한
QUERY
보인다. 따라서 첫 번째 요청에는 유효한 변수 filter
이 있어야하며이 변수는 래핑 된 구성 요소에 만들어야합니다.
graphcool을 사용하여 필터를 작동시킬 수 없으며 개체를 어린이 등으로 전달할 수 없다고 명시되어 있습니다. 거기에서 어디로 가야하는지에 대한 아이디어가 있습니까? –