fix: use non-namespaced apollo-angular imports #1186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes a longstanding issue with being unable to write jest tests using generated services from
@graphql-codegen/typescript-apollo-angular
. The generated services file will now include:instead of:
This was the suggested approach mentioned in #223 and #28 and seemed like a relatively straightforward fix that should have minimal impact on projects already using this library.
Related #223 and #28
Type of change
Please delete options that are not relevant.
Screenshots/Sandbox (if appropriate/relevant):
Without this fix in places, users that attempt to use generated service files in their jest tests will see the following error:
How Has This Been Tested?
Up until this point I've been manually running a script to swap out the imports as part of codegen's
afterAllFileWrite
hook which gets rid of the issue.Test Environment:
@graphql-codegen/typescript-apollo-angular
:Checklist:
CONTRIBUTING doc and the
style guidelines of this project
Further comments
One other possible fix to this problem would be to address the namespace issue present in the
jest-preset-angular
plugin. There's an open issue around this issue:thymikee/jest-preset-angular#963
However I was unsure how to fix that library and the tweak to this library seemed far more straightforward.