I am using react-apollo for graphql query. I want to show a single object for category so for that I need an id which I can get from navigation.state.params.id. I did the following but I am getting an error of "Cannot read property 'skip' of undefined " . How should I solve this issue?
Here is my code
class CategoryDetail extends React.PureComponent {
render() {
console.log("props in detail", this.props);
return (
<View style={{ flex: 1 }}>
<Text>Category View</Text>
</View>
);
}
}
const CATEGORY_DETAIL_QUERY = gql`
query CATEGORY_DETAIL_QUERY($id: ID!) {
category(id: $id) {
id
name
}
}
`;
export default graphql(CATEGORY_DETAIL_QUERY, {
options: props => {
variables: {
id: props.navigation.state.params.id;
}
},
})(CategoryDetail);
I am using react-apollo for graphql query. I want to show a single object for category so for that I need an id which I can get from navigation.state.params.id. I did the following but I am getting an error of "Cannot read property 'skip' of undefined " . How should I solve this issue?
Here is my code
class CategoryDetail extends React.PureComponent {
render() {
console.log("props in detail", this.props);
return (
<View style={{ flex: 1 }}>
<Text>Category View</Text>
</View>
);
}
}
const CATEGORY_DETAIL_QUERY = gql`
query CATEGORY_DETAIL_QUERY($id: ID!) {
category(id: $id) {
id
name
}
}
`;
export default graphql(CATEGORY_DETAIL_QUERY, {
options: props => {
variables: {
id: props.navigation.state.params.id;
}
},
})(CategoryDetail);
Share
Improve this question
asked Nov 8, 2017 at 9:40
SerenitySerenity
4,0648 gold badges49 silver badges98 bronze badges
2
- Can you tell us in what file and on what line this error occurs? – Tvde1 Commented Nov 8, 2017 at 9:51
- TypeError: Cannot read property 'skip' of undefined This error is located at: in Apollo(CategoryDetail) (at SceneView.js:32) – Serenity Commented Nov 8, 2017 at 9:53
1 Answer
Reset to default 4Skip is one of the options Apollo checks. In your code, the options function is not returning anything.
Arrow functions return what is after => unless it is a {} block, in which case the return is to be defined inside the declared function body. If you want to return an object, which shares the same syntax as a code block, you need to wrap it inside ().
options: props => ({ variables: ... })