1

I have a nextjs & typescript & apollo-client app that communicates with a GraphQL API and it uses code-gen to generate types using the introspection in development environment. It works well in dev so no questions here.

In production we have introspection disabled due to some security matters and code-gen cannot be used here.

The current approach is committing the code-gen outputs to the repository. And the wanted approach is to generate types when the docker creates the container by running the command.

How do I generate the types in production when the introspection is disabled?

kakakakakakakk
  • 467
  • 10
  • 31

1 Answers1

1

Using one approach in dev-env and another in prod is inherently error prone.

Perhaps these links / approaches could be of help ?

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

https://www.the-guild.dev/graphql/codegen

Perhaps you can generate code in dev using above and then push same to prod. This would also implicitly make the approach consistent between dev and prod (generate code offline in dev env and use the same in prod).

This could help with CI/CD pipeline if you are into it as well.

Ravindra HV
  • 2,558
  • 1
  • 17
  • 26