Skip to content

feat: implement GraphQL API with Apollo Server#286

Merged
Aamod-Dev merged 7 commits into
niharika-mente:mainfrom
YLaxmikanth:feature/graphql-api
Jun 22, 2026
Merged

feat: implement GraphQL API with Apollo Server#286
Aamod-Dev merged 7 commits into
niharika-mente:mainfrom
YLaxmikanth:feature/graphql-api

Conversation

@YLaxmikanth

Copy link
Copy Markdown
Contributor

Description

Implemented a GraphQL API alongside the existing REST API using Apollo Server.

Features Added

  • Apollo Server integration
  • GraphQL endpoint at /graphql
  • Product, User, and Order GraphQL types
  • Queries for Products, Users, and Orders
  • Mutations for Product and User management
  • Resolver layer using existing MongoDB models
  • Apollo Sandbox support
  • GraphQL API documentation and usage examples

Technical Changes

  • Added GraphQL schema definitions
  • Added query and mutation resolvers
  • Integrated Apollo Server with the existing Express backend
  • Added GraphQL documentation under BACKEND/graphql/README.md

Benefits

  • Flexible data fetching
  • Reduced over-fetching
  • Foundation for future GraphQL enhancements

Fixes #275

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@YLaxmikanth is attempting to deploy a commit to the niharika-mente's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Aamod-Dev Aamod-Dev added SSoC26 Hard enhancement New feature or request backend For changes related to the Express server, API routes, or MongoDB models labels Jun 18, 2026
@Aamod-Dev

Copy link
Copy Markdown
Collaborator

Review: GraphQL API implementation with Apollo Server. Very significant architectural addition. Verify: Apollo Server setup, schemas and resolvers for products/orders/users, query and mutation coverage, subscriptions for real-time updates, GraphQL playground access, coexistence with REST API, migration path. Document GraphQL endpoints. Hard difficulty appropriate. Status: Needs architecture review and testing.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid GraphQL integration with Apollo Server and express4 middleware. Well-defined schema covering Product/User/Order with CRUD mutations. Note: graphql v17 requires Node.js >=22 — ensure deployment uses compatible runtime. Safe to merge.

@Aamod-Dev

Copy link
Copy Markdown
Collaborator

PR has merge conflicts preventing clean merge. Please rebase on main.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request Changes

  • resolvers.js is imported in server.js but missing from the PR. Server will crash on startup.
  • graphql@17.0.1 requires Node >=22 and is incompatible with @apollo/server@5.5.1 (requires graphql@^16.11.0). Downgrade to graphql v16.
  • No auth/authorization on the GraphQL endpoint.

@Aamod-Dev

Copy link
Copy Markdown
Collaborator

Missing resolvers, incompatible deps

@Aamod-Dev Aamod-Dev closed this Jun 20, 2026
@Aamod-Dev Aamod-Dev reopened this Jun 20, 2026
@YLaxmikanth

Copy link
Copy Markdown
Contributor Author

Hi @Aamod-Dev,

I've addressed the requested changes:

  • Downgraded graphql to a compatible v16 release.
  • Added authentication context to the GraphQL endpoint using the existing auth middleware.
  • Verified and included graphql/resolvers.js in the implementation.
  • Rebased the branch on the latest main and resolved merge conflicts.

Could you please take another look when convenient?

Thank you!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approved!

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs changes: There are merge conflicts. Please resolve them.

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Critical Security Flaw: The GraphQL mutations (createProduct, updateProduct, deleteProduct, createUser, deleteUser) have no authorization checks. Unauthenticated users can currently hit the /graphql endpoint and manipulate products and users.
  • Missing Business Logic: Product mutations in GraphQL bypass the core business logic (Elasticsearch indexing and Redis cache invalidation), which will lead to the search index and cache falling out of sync.
  • Hard Delete vs Soft Delete: The deleteProduct mutation uses a hard delete (findByIdAndDelete), breaking the existing soft delete pattern (isDeleted: true) used elsewhere in the application.

@YLaxmikanth

Copy link
Copy Markdown
Contributor Author

Hi @Aamod-Dev,

I've addressed the latest review comments:

  • Added authorization checks for GraphQL mutations using the authenticated user context.
  • Replaced hard product deletion with the existing soft-delete approach (isDeleted: true).
  • Integrated Elasticsearch indexing/removal and Redis cache invalidation into GraphQL product mutations to keep search and cache behavior consistent with the REST API.

Could you please take another look when convenient?

Thank you!

@Aamod-Dev

Copy link
Copy Markdown
Collaborator

Look for ci pipeline errors

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All review feedback addressed: resolvers.js added, graphql downgraded to v16, mutations secured with auth, Elasticsearch + Redis integration included, soft delete pattern used. Minor note: coupon routes were removed in merge — will restore separately. Approving.

@Aamod-Dev Aamod-Dev merged commit 93c5106 into niharika-mente:main Jun 22, 2026
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend For changes related to the Express server, API routes, or MongoDB models enhancement New feature or request Hard SSoC26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Implement GraphQL API

2 participants