graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Option importDocumentNodeExternallyFrom for near-operation-file only imports JS files, but should support TS

Open bohdanbirdie opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

When using importDocumentNodeExternallyFrom: near-operation-file with documentMode: external the imported operation is expected to be a *.js file

See: https://github.com/dotansimha/graphql-code-generator/blob/47d0a57e27dd0d2334670bfc6c81c45e00ff4e74/packages/plugins/other/visitor-plugin-common/src/client-side-base-visitor.ts#L487

Describe the solution you'd like

Add another config property to change the import file format or inherit it from the operation.

Describe alternatives you've considered

Not using importDocumentNodeExternallyFrom

Additional context

image

bohdanbirdie avatar Sep 20 '22 13:09 bohdanbirdie

Actually, it probably makes sense not to have the extension at all for the imports

bohdanbirdie avatar Sep 20 '22 13:09 bohdanbirdie

Hi @bohdanbirdie,

Could you update all your @graphql-codegen/* packages to the last version? A path has been released that should fix your issue.

charlypoly avatar Oct 11 '22 09:10 charlypoly

Thanks, @charlypoly I tried to do it quickly, but looks like the config file format has been changed from yaml to json, so I will take me a while to edit that

But I can see that the related PR is merged and it looks right to me, so I'll close this issue, and if that won't work for me later I'll re-open it

Thanks again!

bohdanbirdie avatar Oct 20 '22 06:10 bohdanbirdie