refactor(graphql): Generate initial app types from schema#3911
Draft
effigies wants to merge 17 commits intoOpenNeuroOrg:masterfrom
Draft
refactor(graphql): Generate initial app types from schema#3911effigies wants to merge 17 commits intoOpenNeuroOrg:masterfrom
effigies wants to merge 17 commits intoOpenNeuroOrg:masterfrom
Conversation
Add a minimal `dump-schema` yarn script to the monorepo.
Two-step pipeline: dump-schema writes SDL, then graphql-codegen generates TypedDocumentNode types for openneuro-app. - codegen.ts at repo root with client-preset, fragment masking off - codegen and codegen:check scripts in root package.json - @graphql-typed-document-node/core added to openneuro-app deps - Several document sources excluded due to duplicate operation names and type mismatches (to be resolved in subsequent tasks)
Replace gql tagged templates with graphql() from the generated helper. Fix $links type mismatch ([String] -> [String!]) to match schema. Rename advancedSearchDatasets to UserAdvancedSearchDatasets to resolve duplicate operation name with use-search-results.tsx. Re-include user.ts in codegen document scanning. Downstream consumer type errors (user-datasets-view.tsx, user-query.tsx, etc.) are expected and will be resolved in subsequent tasks.
Replace hand-written User and Dataset types from user-types.ts with generated types from graphql-codegen in all consumer files. - User type derived as NonNullable<UserQuery["user"]> - Dataset type derived from UserAdvancedSearchDatasetsQuery edge nodes - Component prop interfaces (UserRoutesProps, UserCardProps, etc.) relocated to their consuming component files - OutletContextType moved to user-routes.tsx - SearchInput replaced with DatasetSearchInput, string sort values replaced with SearchSortOption enum - Admin pages extend User type with `modified` field (not in GET_USER query, pending GET_USERS migration to codegen) - SearchResultsCitation uses minimal CitationDataset interface to accept datasets from multiple query sources - NotificationHeader uses minimal User interface compatible with both generated and hand-written User types (event-types.ts bridge) - user-notifications-context.tsx casts generated notifications to Event type for mapRawEventToMappedNotification (Task 6 bridge) - Test fixtures updated with required `created` field and enum values - GitHubAuthButton.sync prop widened to accept string | Date | null No file except event-types.ts now imports from user-types.ts.
All GraphQL-derived types now come from codegen output. Component prop interfaces relocated to their consuming components. event-types.ts updated to import User from generated types.
Replace gql tagged templates with graphql() from generated helper. Fix duplicate operation name: rename second SaveAdminNote to UpdateAdminNote. Re-include datasetEvents.ts in codegen document scanning and regenerate types.
Replace all imports from types/event-types.ts with generated types from graphql-codegen. Non-GraphQL exports (MappedNotification, formatStatusForDisplay, mapRawEventToMappedNotification) are relocated to a new notification-mapper.ts module in the notifications directory. - Use ResponseStatusType enum instead of string literal unions for mutation variables (processContributorRequest, processContributorCitation) - Use NotificationStatusType for updateEventStatus/updateNotificationStatus - Derive DatasetEvent and Notification types from generated query results - Remove invalid 'reason' param from processContributorCitation call (the mutation schema does not accept it) - Zero files now import from event-types.ts
All GraphQL-derived types now come from codegen output. UI mapping functions relocated to notifications/notification-mapper.ts.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3911 +/- ##
==========================================
+ Coverage 48.87% 53.61% +4.74%
==========================================
Files 680 685 +5
Lines 37665 41737 +4072
Branches 1867 1881 +14
==========================================
+ Hits 18408 22378 +3970
- Misses 19098 19200 +102
Partials 159 159 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR establishes a process for converting openneuro-app types from hand-written to generated. It:
If we're happy with this, I would suggest making further changes in a separate PR to keep the infrastructure changes separated from the majority of the mostly-mechanical type changes.
I will not have time to work on this further until after this coming week. Feel free to examine or ignore.
Builds on #3910, so those changes are duplicated here.