Skip to content
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

importDocumentNodeExternallyFrom doesn't work #10153

Open
itpropro opened this issue Sep 25, 2024 · 0 comments
Open

importDocumentNodeExternallyFrom doesn't work #10153

itpropro opened this issue Sep 25, 2024 · 0 comments

Comments

@itpropro
Copy link

itpropro commented Sep 25, 2024

Which packages are impacted by your issue?

visitor-plugin-common

Describe the bug

The setting importDocumentNodeExternallyFrom implemented here

`import * as Operations from '${this.clearExtension(this.config.importDocumentNodeExternallyFrom)}';`

doesn't work as documented.
As documented in on documentMode

external: document nodes are imported from an external file. To be used with importDocumentNodeExternallyFrom

and on `` itself

any string: This would be the path to import document nodes from. This can be used if we want to manually create the document nodes e.g. Use graphql-tag in a separate file and export the generated document

The only thing that it currently does is adding an import line to the generated file like this

import * as Operations from 'ANY_STRING';

This does not help for using external document nodes. It would be expected that either every type and operation in the file is prefixed with Operations. or that the proper imports from the given path are added (preferred).
Now it just generates a file that is missing all type and operation references.

Steps to Reproduce the Bug or Issue

  1. Set documentMode to external
  2. Set importDocumentNodeExternallyFrom to the path of the generated types and operations
  3. Look if the generated file has all references correct

Expected behavior

Add correct import statements for each used type and operation from the provided path.
Alternatively provide an option to prefix every operation with the imported object prefix, in this case Operations.. Currently there is only typesPrefix for types, nothing for operations.

Screenshots or Videos

No response

Platform

  • OS: macOS, Windows, Linux
  • NodeJS: 20
  • graphql version: 16.9
  • @graphql-codegen/* version(s): current

Codegen Config File

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant