dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.86k stars 1.33k forks source link

Namespace imports clashing with Native ESM imports (Vue-Apollo/Vite) #4816

Closed Drakota closed 4 years ago

Drakota commented 4 years ago

Is your feature request related to a problem? Please describe. While trying to make Vue-Apollo plugin work nicely with vite & Vue 3, I've runned into an issue with how the generated code handles imports.

Since Native ES modules handles imports differently, those lines causes issues

import * as VueApolloComposable from '@vue/apollo-composable';
import * as VueCompositionApi from '@vue/composition-api';

image

Repo demonstrating the issue

Describe the solution you'd like It should be something like this instead.

import VueApolloComposable from '@vue/apollo-composable';
import VueCompositionApi from '@vue/composition-api';

Describe alternatives you've considered The vue-apollo codegen plugin could either allow to completly disable the imports and use the plugin add to manually write imports or a property like prioritizeDefaultImports that would just use the default import instead of an namespace import.

I'd be more than happy to offer my help on any implementation to fix this issue. 😀

P4sca1 commented 4 years ago

@vue/apollo-composable and @vue/composition-api do not provide default exports so it is correct to use import * as imports.

dotansimha commented 4 years ago

@P4sca1 thank you for clarifying. Closing.