apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Doest v5 support TS GraphQL Generator with Codegen ?

Open productdevbook opened this issue 3 years ago • 6 comments

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

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

productdevbook avatar Oct 19 '22 12:10 productdevbook

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

Diizzayy avatar Oct 19 '22 12:10 Diizzayy

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>

tkofh avatar Nov 23 '22 16:11 tkofh

@tkofh Ofcourse, PRs are welcomed for review.

Diizzayy avatar Nov 23 '22 18:11 Diizzayy

any update?

cdwmhcc avatar Dec 14 '22 23:12 cdwmhcc

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

resessh avatar Dec 18 '22 18:12 resessh

@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.

FranciscoKloganB avatar May 22 '23 17:05 FranciscoKloganB