menu

Apollo

A community of developers, designers and others who love Apollo and GraphQL. 🚀

Channels
Team

Generating TypeScript based on .gql files

June 10, 2020 at 9:13pm

Generating TypeScript based on .gql files

June 10, 2020 at 9:13pm
Hi, we are using https://github.com/detrohutt/babel-plugin-import-graphql to import GQL queries into our code.
It seems like when we use
apollo codegen:generate \ --excludes=nodemodules/ \ --includes=src/**/.gql \ --endpoint https://endpoint/graphql \ --header "Authorization: Bearer $JWT" \ --target typescript \ --outputFlat src/_generated
The queries are parsed. However, the the #import declarations do not work. Has anyone ever used apollo-tooling together with .gql files?
I'm thinking of writing a script that recursively follows the imports and merges everything in one file. But this seems to be a little overkill :(

June 11, 2020 at 12:18am
I don't use that plugin, but I think you should be able to use GraphQL Code Generator with it, provided your import syntax matches graphql-import syntax
  • reply
  • like
graphql-codegen is a much more robust tool than Apollo's
  • reply
  • like