Fix: GraphQL input names, JWT type, and product count query #29
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.
🚀 Backend Stability & Type Safety Enhancements (Authentication, Data Access)
This pull request introduces several crucial fixes to improve the type safety, schema adherence, and overall reliability of the e-commerce GraphQL backend, particularly within the authentication and data access layers.
🔒 Authentication Layer Refinement
1. GraphQL Input Schema Compliance
The
registerandloginmutations have been updated to correctly use structured GraphQL Input Types (Input!), resolving runtime issues and ensuring strict adherence to the defined schema. This provides a smoother developer experience when testing in tools like GraphQL Playground.register(email: String!, password: String!, name: String!)(input: RegisterInput!)login(email: String!, password: String!)(input: LoginInput!)2. New Validation Constraint
A crucial validation step has been implemented to control input size:
3. Type-Safe JWT Payload Correction
In
auth.service.ts, the construction of the JSON Web Token (JWT) payload was corrected to resolve type errors and guarantee successful token signing/decoding.jwtService.sign()is now explicitly constructed as a type-safe object ({ userId, email }), ensuring the generated tokens contain the expected claims in the correct structure.💾 Data Access Layer (Mongoose)
4. Mongoose Deprecation Fix in
product.repo.tsThe method used to retrieve the total product count was updated to address Mongoose deprecation warnings and improve performance for count operations.
.find().count().countDocuments()This update resolves associated warnings and future-proofs the data repository against upcoming Mongoose library changes.
✅ Summary of Key Changes
Input!types for all auth mutations..countDocuments().