Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upmissing result options in SubscriptionOptions #1014
Comments
For anyone looking for a work around - overwriting this type worked for me:
import 'vue-apollo'
declare module 'vue-apollo/types/options' {
interface VueApolloSubscriptionDefinition<Variables = OperationVariables>
extends Omit<SubscriptionOptions<Variables>, 'variables'> {
variables?: QueryVariables<Variables>
result?: (result: ApolloQueryResult<Result>, key: string) => void
client?: string
}
} It's worth saying the alternative syntax is also affected by this issue (not surprising, but in case anyone tries it anyway like I did): {
...
created() {
this.$apollo.addSmartQuery("usbDisksChanged", {
query: OnUsbdisksChanged,
result({ data }: any) {
let disks: UsbDisk[] = data.usbDisksChanged;
Vue.set(this, 'usbdisks', disks); // <- this is VueComponent
}
})
}
} Otherwise, using a standard query might be sufficient for the next person's needs, as per the docs |
Describe the bug
Missing
result
options inSubscriptionOptions
To Reproduce
On line 28, the result will fail to pass 'type check' or 'compile' from typescript compiler, reporting:
The code after compiled can run without problem. (I set only to use typescript compiler to do type check in webpack configuration)
Expected behavior
result
should pass the type-check and compilingVersions
vue: 2.6.11
vue-apollo:3.0.3
apollo-client:2.6.9
vue-class-component: 7.2.3
*** Additional Context***
I guess the problem is here? Missing a definition to
result
?vue-apollo/packages/vue-apollo/types/options.d.ts
Lines 84 to 87 in b13d688