Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Apollo codegen to graphql-code-generator #999

Merged
merged 7 commits into from Aug 12, 2022

Conversation

mipyykko
Copy link
Collaborator

@mipyykko mipyykko commented Aug 10, 2022

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-generatoras 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 exporting gql 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.

@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #999 (c432927) into master (de697eb) will increase coverage by 0.00%.
The diff coverage is 86.66%.

@@           Coverage Diff           @@
##           master     #999   +/-   ##
=======================================
  Coverage   68.34%   68.35%           
=======================================
  Files         104      104           
  Lines        4041     4042    +1     
  Branches      890      888    -2     
=======================================
+ Hits         2762     2763    +1     
  Misses       1194     1194           
  Partials       85       85           
Flag Coverage Δ
backend 68.33% <86.66%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
backend/api/completions.ts 67.34% <ø> (ø)
backend/graphql/Completion/index.ts 100.00% <ø> (ø)
backend/graphql/Course/index.ts 100.00% <ø> (ø)
backend/graphql/StudyModule/index.ts 100.00% <ø> (ø)
backend/graphql/Upload.ts 100.00% <ø> (ø)
backend/graphql/User/index.ts 100.00% <ø> (ø)
backend/graphql/UserCourseProgress.ts 37.50% <0.00%> (ø)
backend/graphql/index.ts 100.00% <ø> (ø)
backend/schema.ts 77.27% <ø> (ø)
backend/graphql/CompletionRegistered.ts 46.77% <50.00%> (-0.77%) ⬇️
... and 6 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mipyykko mipyykko force-pushed the refactor-apollo-codegen-to-graphql-codegen branch from 03f8e71 to 693ef36 Compare August 12, 2022 10:25
@mipyykko mipyykko force-pushed the refactor-apollo-codegen-to-graphql-codegen branch from 693ef36 to c432927 Compare August 12, 2022 11:32
@mipyykko mipyykko marked this pull request as ready for review August 12, 2022 11:43
@mipyykko mipyykko merged commit d407131 into master Aug 12, 2022
@mipyykko mipyykko deleted the refactor-apollo-codegen-to-graphql-codegen branch August 12, 2022 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Look to remove apollo-cli? Type generation not working now unless downgrading graphql
1 participant