Add more documentation on how to write plugins in TypeScript
See original GitHub issueIs your feature request related to a problem? Please describe.
Since I’m in an Angular environment I wanted to write my plugin in TypeScript. However the only thing in the documentation is this info that you need to compile your plugin before you can run it with gql-gen
.
What I found out by code-surfing through your repo: codegen-templates-scripts build
codegen-templates-scripts build
worked, tsc
did not
I would contribute to the docs but I don’t know your prefered way of doing this
Describe the solution you’d like Make TypeScript users happy 🙂 Every plugin in your repo is written in TypeScript and yet you have only docs for vanilla js
Describe alternatives you’ve considered Writing everything in JavaScript after hours of debugging
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Module: Plugin - TypeScript: Documentation
This example shows how to have multiple overloads for your function */ ... Some plugins add or modify top-level exports on existing modules....
Read more >Plugin Development Workflow | Capacitor Documentation
Plugin Development Workflow. With the new plugin created, you can begin implementing functionality across a variety of platforms.
Read more >TypeScript | Plugin API - Figma
It is an extension of the JavaScript language. You can write JavaScript code, paste it into a TypeScript file. Congratulations, you've just written...
Read more >TypeScript | CLion Documentation - JetBrains
Make sure the JavaScript and TypeScript plugin is enabled in the settings. Press Ctrl+Alt+S to open the IDE settings and select Plugins. Click ......
Read more >TypeScript and Gatsby
Read the Gatsby Config API documentation to learn more about its different options. gatsby-node.ts. Support added in gatsby@4.9.0. You can import ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @kroeder
Codegen plugins has a very simple interface you need to follow: https://github.com/dotansimha/graphql-code-generator/blob/master/packages/graphql-codegen-core/src/yml-config-types.ts#L67-L71
You can use JavaScript or TypeScript to write it. If you wish to use TypeScript, you need to compile your code with
tsc
orbabel
. If you wish to use Handlebars, you can either add your Handlebars template as string in your TypeScript code file, or you can load it from a.handlebars
file (using your preferred way - either with a bundler like Webpack or similar).During the recent releases, we tried to avoid using Handlebars as integrated part of the codegen, and only use it inside the plugins. In matter of fact, we are looking for a better alternative for implementing the plugins, without using Handlebars at all, so I can’t recommend you to use it. That’s also the reason that we are keeping it as internal and not exposing or documenting it at the moment.
I can recommend on trying to implement it in an easier way using
visit
(see https://github.com/dotansimha/graphql-code-generator/pull/917 for examples, I’m trying to do it now for the Flow plugin).Have you tried to write a plugin in typescript by just reading the docs and use
tsc
in combination with handlebars? As mentioned in my opening post: I was not able to do thatI only figured everything out by putting in a lot of effort and reading your implementations and build scripts you are using yourself (+ this wrapper you are using is not in the documentation so I really am afraid that these are going to break without e.g. a major release because they are not part of the public documentation 🙁 )
If you also want people to start code-surfing in order to figure out how this works, then I suggest to put at least the link “packages/plugins” into the documentation
If you think it’s fine that way I can live with that. I just want to improve things for others and post about issues I had 🙂