dotansimha / graphql-code-generator-community

MIT License
118 stars 155 forks source link

Vue3 compatibility for vue-apollo-smart-ops #179

Open greydelta opened 2 years ago

greydelta commented 2 years ago

Is your feature request related to a problem? Please describe.

Currently, TypeScript Vue Apollo Smart Operations imports vue-apollo-smart-ops upon file generation

The issue is vue-apollo-smart-ops's dependency is using vue-apollo v3 (only supports Vue2) and will trigger an error below:

image

Describe the solution you'd like

Hence, I hope to see vue-apollo-smart-ops's dependency updated to vue-apollo v4 with support for Vue3

Describe alternatives you've considered

For now, the workaround seems to be using TypeScript Vue Urql which works well~!

Additional context

vue-apollo v4 package in alpha

vknowles-rv commented 2 years ago

Opened a PR to support new vue/vue-apollo versions: https://github.com/equalogic/vue-apollo-smart-ops/pull/161

Hopefully the maintainer is able to review.

Just FYI, it is possible to provide a custom source to import operations from. May be possible to fork the branch from the PR above and see how things go. You will need to update where ApolloError imports from via vueApolloErrorTypeImportFrom

example

generates:
  ./autogenerated/types/graphql.ts:
    plugins:
      - typescript
      - typescript-operations
      - typescript-vue-apollo-smart-ops
    config:
      vueApolloErrorTypeImportFrom: '@apollo/client/core'
vknowles-rv commented 2 years ago

Discontinued my effort to update vue-apollo-smart-ops because I am using apollo composable.

IMO, typed-document-node documentation should be used instead as it will be supported by most popular graphql libraries (easy to implement manually as well).