Migrate from Apollo codegen to graphql-code-generator #999
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've created the frontend types with Apollo's own CLI since the beginning, but as it's become increasingly flaky because mismatching dependencies and all, it's better to migrate away from it. Apollo is advocating its new Rover CLI, which does not include the codegen and the developers there seem to be recommending
graphql-code-generator
as codegen replacement anyway.This PR does introduce changes in a lot of files, but most of them are just changing the imports to point at the new generated types and updating the GraphQL operations accordingly. The new generated code also removes a lot of redundant manual query typing, which is nice.
The GraphQL operation and fragment definitions are now all in
frontend/graphql/*
as.graphql
files instead of Typescript files exportinggql
variables. Storing the definitions next to where the operations are actually used might also be a viable alternative, as would be organizing the query/mutation/fragment combinations by usage.The generated code now resides in
frontend/graphql/generated
.graphql-code-generator
does advocate generating the code alongside their definitions, but personally I like them all being in one place.Also included some new documentation on the dev workflow with GraphQL.