zephraph / vue-graphql-loader

Custom block support for GraphQL operations in Vue's single file components
MIT License
50 stars 0 forks source link

Typescript: missing types for this.$options.[query|mutation|subscription] #57

Open georgyfarniev opened 5 years ago

georgyfarniev commented 5 years ago

Hello. The types is missing for component. I tried to add interface (to make PR) from handler.ts to export, but I get error when build my vue app in strict mode:

Property 'myQuery' does not exist on type 'DocumentNode | { [key: string]: DocumentNode; }'.

I'm not a typescript savvy, but I don't know how to solve this problem without declaring this props as any. I asked on stackoverflow

Hope this helps. Thanks in advance.

georgyfarniev commented 5 years ago

I suggest creating custom accessor for non-anonymous queries:

// type of $gql: { [key: string]: DocumentNode; }
this.$gql.query.myQuery

This is shorter than this.$options.query.myQuery and non-breaking