fix(visitor-plugin-common): incorrect gqlImport alias
Description
When I uses the gqlImport config with plugins, which utilizes visitor-plugin-common, it tends to create invalid gql tagged template.
For example, with config, gqlImport: './path/to/pragma#myPragma, it generates like this:
import { myPragma as gql } from './path/to/pragma';
export const SomeQuery = myPragma`
// ^^^^^^^^
`;
Related #5460
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
I have generated some queries which are used in the production, with this modification, in my local. (w/ typescript-document-nodes plugin).
If it needs extra test codes, I'll update it later.
Test Environment:
- OS: macOS 13.1
@graphql-codegen/typescript: 2.7.3@graphql-codegen/typescript-operations: 2.5.3@graphql-codegen/typescript-document-nodes: 4.0.1@graphql-codegen/visitor-plugin-common: 4.0.1- NodeJS: 18.16.1
Checklist:
- [x] I have followed the CONTRIBUTING doc and the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- N/A
- [ ] I have made corresponding changes to the documentation
- N/A
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
Further comments
N/A
🦋 Changeset detected
Latest commit: db8e4babe56bddc72457eb83a1aa6064d8d69184
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 9 packages
| Name | Type |
|---|---|
| @graphql-codegen/visitor-plugin-common | Patch |
| @graphql-codegen/typescript-document-nodes | Patch |
| @graphql-codegen/gql-tag-operations | Patch |
| @graphql-codegen/typescript-operations | Patch |
| @graphql-codegen/typescript-resolvers | Patch |
| @graphql-codegen/typed-document-node | Patch |
| @graphql-codegen/typescript | Patch |
| @graphql-codegen/graphql-modules-preset | Patch |
| @graphql-codegen/client-preset | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Can you please add a changeset as mentioned in https://github.com/dotansimha/graphql-code-generator/pull/9660#issuecomment-1705932124?
I have added them in db8e4babe56bddc72457eb83a1aa6064d8d69184 ! Thank you :)
@HelloWorld017 thank you for your contribution! does it make sense to add a test that covers this case?