Skip to content

Commit

Permalink
Remove extension from operations file import (#8432)
Browse files Browse the repository at this point in the history
Co-authored-by: Charly POLY <1252066+charlypoly@users.noreply.github.com>
  • Loading branch information
mvestergaard and charlypoly committed Oct 11, 2022
1 parent a700a15 commit 1bd7f77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-buckets-sleep.md
@@ -0,0 +1,5 @@
---
"@graphql-codegen/visitor-plugin-common": patch
---

Remove extension from operations file import
Expand Up @@ -483,9 +483,12 @@ export class ClientSideBaseVisitor<
case DocumentMode.external: {
if (this._collectedOperations.length > 0) {
if (this.config.importDocumentNodeExternallyFrom === 'near-operation-file' && this._documents.length === 1) {
this._imports.add(
`import * as Operations from './${this.clearExtension(basename(this._documents[0].location))}.js';`
);
let documentPath = `./${this.clearExtension(basename(this._documents[0].location))}`;
if (this.config.emitLegacyCommonJSImports) {
documentPath += '.js';
}

this._imports.add(`import * as Operations from '${documentPath}';`);
} else {
if (!this.config.importDocumentNodeExternallyFrom) {
// eslint-disable-next-line no-console
Expand Down

0 comments on commit 1bd7f77

Please sign in to comment.