Search code examples
typescriptgraphqlapollo

How to use Apollo Rover + Codegen to generate typescript schema types


I am struggling to understand how to use Apollo Rover in conjunction with Apollo Codegen to generate my typescript types for my API's schema. I registered my schema in apollo studio, and can grab the schema into a GQL file, but it looks like codegen is not supported in the Rover CLI and so I need to use the legacy Apollo CLI. However the Apollo CLI wants schema to be fetched from a remote endpoint and not a registered schema, and wants the schema in JSON format, but Rover only fetches in .gql format.

I'm confused about how I am "supposed" to hook this up so that I can use apollo codegen with my registered schema without a bunch of manual conversion work.


Solution

  • I found this. I think you should keep use Apollo CLI.

    enter image description here

    Rover does not currently provide client-specific features, such as code generation or client checks. For these features, continue using the Apollo CLI.

    Another solution use, it work for me ;)

    https://github.com/dotansimha/graphql-code-generator