menu

Apollo

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

Channels
# All channels
view-forward
# General
view-forward
# Apollo Angular
view-forward
# Announcements
view-forward
# Apollo Android
view-forward
# Apollo Client
view-forward
# Apollo iOS
view-forward
# Apollo Link
view-forward
# Apollo Link Rest
view-forward
# Local State
view-forward
# Apollo Studio
view-forward
# Apollo Server
view-forward
# Apollo Tooling
view-forward
# Contributing
view-forward
# Docs
view-forward
# Events
view-forward
# GraphQL Tools
view-forward
# Jobs
view-forward
# Random
view-forward
# React Apollo
view-forward
# Showcase
view-forward
# Subscriptions
view-forward
# Testing
view-forward
# Vue Apollo
view-forward
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