-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For..of in codegen/core throw errors in programatic usage #2218
Comments
Hi @SorEduard , can you please create a minimal reproduction in a repo or sandbox? |
Hi, sorry for waiting, my college was on exams, i've created two repos, one with the plugin(where the error occurs), and another to test the plugin in webpack, just yarn or npm link the webpack plugin into the test. Plugin: https://github.com/SorEduard/graphql-codegen-plugin Please change the approach from object to array in normalizeCodegenConfig method inside main class to see the two reproduction above. Thank's. |
Hi @SorEduard This is because we allow to pass configuration per each plugin. The correct form of the input should be an array with objects: If you have an array, or object, or string, and you wish to transform it, you can use |
Hi @dotansimha, thanks for the reply, i'll try to use with this approach. i'm not using typescript for this project, for sure i should. Does the webpack plugin package still exist? In readme of this npm package https://www.npmjs.com/package/graphql-codegen-webpack the showed approach isn't equal to the actual version, a webpack plugin increase substantially to the productivity, how about a new implementation? |
@SorEduard We dropped support for Webpack plugin because we couldn't control the way it watches for file changes, and it was very difficult to sync the watch of Webpack with ours. See: #897 (comment) |
Fixed in 1.6.0 |
Firstly, thanks for the library, I love graphql + typescript, but I have some issue in programmatic usage. Sorry about my english.
Describe the bug
When I use programmatic usage(creating a webpack plugin), for..of iteration in plugins object inside configuration, throw an error, but if I use like an array, for interation work's(because for..of is used for this purpose), see:
To Reproduce
Pass an object of plugins in config object on codegen, like:
causes: options.plugins is not iterable,but if I pass an array:
causes: "Plugin 0 does not export a valid JS object with "plugin" function.\n"
Doesn't matters in this example
Doesn't matters in this example
codegen.yml
config file:Expected behavior
Read the required plugin and generate graphql types.
Environment:
@graphql-codegen/...
: 1.4.0Additional context
I think the problem is localized in line 36 on codegen.ts file, because for..of loops can't be used on objects. Using for..in loops, the expected behavior will be achivied
Change file like them:
ExecutePlugin function throw errors in package not containing plugin function(line 17 - execute-plugin.ts), but this iteration cannot resolve package because Object.keys(plugin)[0] (line 37 - codegen.ts) returns 0 every time.
The text was updated successfully, but these errors were encountered: