Refactor: Move GraphQL schema definitions to .gql files#280
Conversation
I've separated the GraphQL schema definitions from `src/gql.ts` into domain-specific `.graphql` files (`src/<domain>/<domain>.graphql`) and a shared `src/schema.graphql`. Here's a summary of what I did: - I created new `.graphql` files under `src/activity`, `src/quiz`, `src/statistics`, and `src/user` for their respective GraphQL type definitions, queries, and mutations. - I created `src/schema.graphql` for common/scalar types, enums, and base Query/Mutation type definitions. - I updated `src/gql.ts` to dynamically load all `.graphql` files using `@graphql-tools/load-files` and merge them using `@graphql-tools/merge`. - The original resolver structure in `*.gql.ts` files remains unchanged and maps correctly to the new schema structure. - I confirmed that all existing tests pass, ensuring the integrity of the GraphQL API after this refactoring. This change improves the modularity and maintainability of your GraphQL schema.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
I've separated the GraphQL schema definitions from
src/gql.tsinto domain-specific.graphqlfiles (src/<domain>/<domain>.graphql) and a sharedsrc/schema.graphql.Here's a summary of what I did:
.graphqlfiles undersrc/activity,src/quiz,src/statistics, andsrc/userfor their respective GraphQL type definitions, queries, and mutations.src/schema.graphqlfor common/scalar types, enums, and base Query/Mutation type definitions.src/gql.tsto dynamically load all.graphqlfiles using@graphql-tools/load-filesand merge them using@graphql-tools/merge.*.gql.tsfiles remains unchanged and maps correctly to the new schema structure.This change improves the modularity and maintainability of your GraphQL schema.