Type definitions
NickClark opened this issue · 4 comments
Just jumping into Moleculer... love what I'm seeing so far! The only problem I'm having right now is using the module with the Typescript starter, since when I import this module it has no types. Any chance those would be coming soon?
Types are fairly complex for use with this module since it does not have a direct interface of its own. It merely acts as a plugin to moleculer-web and indirectly augments the interface and adjusts the possible values for the moleculer service and action schemas. There is no direct interaction with this library by the consumer.
I'm open to thoughts on how types could be implemented for this use case, but up until now I've simply been declaring this as an empty module in my local ambient declarations (declare module 'moleculer-apollo-server';
) to avoid the implicit any
errors that TS will take issue with.
Wow, thanks for such a fast response! Ya... I realized that afterwards. Where are you putting that declare
at? I had added it too, but only VSCode is accepting it, the build is ignoring it. First thing to address is the import of ApolloService, it would be nice if the config there would have hints and comments as to it's usage. As for the rest of the system, I'm still pondering how to pursue it in a type safe way. Up to now, in our app, we have used a schema first approach using https://graphql-code-generator.com . This has been wonderful, because we can use the schema as a single source of truth, and then have generated types for our resolvers, making sure they have properly typed signatures... I'm going to be thinking about how to use this same approach on a per service basis here too... not sure yet how though.
@NickClark Almost done with this. You can refer to this PR and watching if it can be merged soon.
#61
Resolved via #61