ApolloError.js?f55daa5:36 Uncaught (in promise) Error: Network error: Cannot read property 'selections' of null
at new ApolloError (ApolloError.js?f55daa5:36)
at Object.error (QueryManager.js?8f5ff47:115)
at SubscriptionObserver.error (zen-observable.js?8f5ff47:176)
at <anonymous>
我的源代码如下:
{ // resolvers and defaults
resolvers: {
Mutation: {
openModal: (_, args, { cache }) => {
const {name} = args
cache.writeData({
modal: {
name,
open: true,
__typename: 'Modal',
},
})
return null
},
closeModal: (_, __, {cache}) => {
cache.writeData({modal: {open: false}})
}
}
},
defaults: {
modal: {
__typename: 'Modal',
open: false,
name: ''
}
}
}
graphql(
gql`
mutation openModal ($name: String!) {
openModal (name: $name) @client
}
`
)(
({mutate}) => {
return (
<div>
<button onClick={() => mutate({ variables: { name: 'test' }})} >Open</button>
</div>
)
}
)
单击按钮时,会出现错误消息。有什么想法吗?
顺便说一句,我在next中使用。js。