Graphql-code-generator: Custom plugin script can't be found

Created on 23 Nov 2018  Â·  9Comments  Â·  Source: dotansimha/graphql-code-generator

Describe the bug
I can't use a custom plugin; simply followed the instructions here: https://graphql-code-generator.com/docs/custom-codegen/write-your-plugin

See repo in "To Reproduce"

[11:40:07] Parse configuration [started]
[11:40:07] Parse configuration [completed]
[11:40:07] Load schema [started]
[11:40:07] Load schema [completed]
[11:40:07] Generate outputs [started]
[11:40:07] Generate ./src/types.d.ts [started]
[11:40:07] Generate ./src/test-plugin-types.d.ts [started]
[11:40:07] Generate [started]
[11:40:07] Generate [started]
[11:40:07] Generate [failed]
[11:40:07] → Unable to find template plugin matching test-plugin.js
[11:40:08] Generate ./src/test-plugin-types.d.ts [failed]
[11:40:08] → Unable to find template plugin matching test-plugin.js
Something went wrong
[11:40:08] Generate [completed]
[11:40:08] Generate ./src/types.d.ts [completed]
[11:40:08] Generate outputs [failed]

To Reproduce
Could reproduce it here: https://github.com/kroeder/gql-gen-custom-plugin-issue-repo
Anything I got totally wrong?

It would help if the error message would show a full path instead just the filename

Expected behavior
Script in my plugin would be executed

Environment:

  • OS: Windows 10
  • Codegen: ^0.14.0
  • Node: ^10.12.10
bug core waiting-for-release

All 9 comments

@kroeder Nice! It should be a relative or an absolute path: ./test-plugin.js. That's because the codegen uses require to load plugins.

Do you think you're be able create a PR that fixes docs? I can help you with that :)

I can contribute, but it still fails

[14:19:39] Parse configuration [started]
[14:19:39] Parse configuration [completed]
[14:19:39] Load schema [started]
[14:19:39] Load schema [completed]
[14:19:39] Generate outputs [started]
[14:19:39] Generate ./src/types.d.ts [started]
[14:19:39] Generate ./src/test-plugin-types.d.ts [started]
[14:19:39] Generate [started]
[14:19:39] Generate [started]
[14:19:40] Generate [failed]
[14:19:40] → Unable to find template plugin matching ./test-plugin.js
[14:19:40] Generate ./src/test-plugin-types.d.ts [failed]
[14:19:40] → Unable to find template plugin matching ./test-plugin.js
[14:19:40]Something went wrong
 Generate [completed]
[14:19:40] Generate ./src/types.d.ts [completed]
[14:19:40] Generate outputs [failed]

using

schema: schema.json
overwrite: true
generates:
  ./src/types.d.ts:
    plugins:
      - typescript-common
      - typescript-client
  ./src/test-plugin-types.d.ts:
    - ./test-plugin.js

Edit: Also, why does schema.json work without being ./schema.json ?

915 should fix it

Awesome! Can confirm, absolute path does work 🙂 I'll use that and wait for a patch release, thanks

Do you still need a documentation update or is 'path.js' instead of './path.js' valid?

@kroeder I'll make it work even as path.js in a minute.

@kroeder Could you check if 0.15.0-alpha.274b13b3 works for you?

Works as expected but something else changed without changing anything in my config
https://github.com/kroeder/gql-gen-custom-plugin-issue-repo/commit/e7f90960d3fbce5e6524005294d4ddb08bf51ad8#r31431497

Is this an expected behavior?

Here's the proof that your fix has worked https://github.com/kroeder/gql-gen-custom-plugin-issue-repo/blob/master/src/test-plugin-types.d.ts

@kroeder We recently changed the name of the enums values to math all other naming conventions.

Fixed in 0.14.2 🎉

Was this page helpful?
0 / 5 - 0 ratings