nuxt-modules / apollo

Nuxt.js module to use Vue-Apollo. The Apollo integration for GraphQL.
https://apollo.nuxtjs.org
MIT License
956 stars 198 forks source link

Doest v5 support TS GraphQL Generator with Codegen ? #440

Open productdevbook opened 2 years ago

productdevbook commented 2 years ago

https://www.the-guild.dev/graphql/codegen/plugins/typescript/typescript-vue-apollo

This support would be great. It is easier to write as Ts.

Diizzayy commented 2 years ago

GraphQL Codegen isn't currently supported nor is it planned as yet.

tkofh commented 2 years ago

Would the maintainers accept a PR that implements codegen? Would be amazing if a graphql/ folder was read and composables were auto-imported for each query in the files in that folder.

i.e.:

# ~/graphql/Users.graphql
query Me {
  name
  email
}
<script setup lang="ts">
// auto-imported
const { data, loading } = useUsersMeQuery()
</script>
Diizzayy commented 2 years ago

@tkofh Ofcourse, PRs are welcomed for review.

cdwmhcc commented 1 year ago

any update?

resessh commented 1 year ago

Using the new client-preset recommended by GraphQL Code Generator, I was able to generate type defs without having to create a new code generator.

Here is a minimum example: https://github.com/resessh/nuxt3-apollo-example

FranciscoKloganB commented 1 year ago

@resessh followed your guide, works partially on my case. TypeScript keeps screaming at me because gql.ts has explicit any and I can't disable that check. :(

It also complains about duplicate types being generated if I enable TypeScript plugin.