Files
tilbudgivern/archive/docs/GRAPHQL_MIGRATION_STATUS.md
alexpolo1 4a372d2e28 clean up
2025-10-30 18:28:58 +00:00

4.9 KiB

GraphQL Migration Status

Completed (2/3 Critical Endpoints)

1. Offers/Quotes - FinalReview

  • Endpoint: POST /api/ordrestyring/offers/create
  • Frontend: frontend/src/components/FinalReview.js
  • Status: Fully migrated to GraphQL
  • Test: test_graphql_offer_creation.js - ALL TESTS PASSED
  • Features:
    • Creates offers with customer info
    • Creates offer lines (materials + labor)
    • Returns offer number and ID
    • Provides direct link to Ordrestyring

2. Calendar/Hours

  • Endpoints:
    • GET /api/calendar - List hours
    • GET /api/calendar/stats - Statistics
    • GET /api/calendar/:id - Single entry
    • POST /api/calendar/sync - Legacy sync
    • GET /api/calendar/hour-types - Hour types
  • Frontend: Not actively used yet (calendar component not implemented)
  • Status: Fully migrated to GraphQL
  • Test: test_graphql_calendar.js - ALL TESTS PASSED
  • Features:
    • Direct GraphQL queries (no sync needed)
    • Date range filtering
    • Statistics calculation
    • Hour types lookup

⚠️ Remaining Critical (1/3)

3. Work Breakdown - LaborInput ⚠️ NEXT PRIORITY

  • Endpoint: GET /api/ordrestyring/case/:caseNumber/work-breakdown
  • Frontend: frontend/src/components/LaborInput.js (lines 87, 290)
  • Usage: Called when user enters case number to fetch work breakdown
  • Status: Still using REST v2 API
  • Migration needed: Migrate to GraphQL cases query

📋 Other Endpoints (Low Priority - Legacy/Testing)

Most of these are not actively used by the frontend:

Testing/Info Endpoints

  • GET /api/ordrestyring/test - REST API test
  • GET /api/ordrestyring/test-graphql - GraphQL test
  • GET /api/ordrestyring/info - API info

Data Endpoints (Not in REST v2 API)

  • GET /api/ordrestyring/cases - Cases list
  • GET /api/ordrestyring/cases/:id - Single case
  • GET /api/ordrestyring/customers - Customers list
  • GET /api/ordrestyring/customers/:id - Single customer
  • GET /api/ordrestyring/invoices - Invoices list
  • GET /api/ordrestyring/invoices/:id - Single invoice
  • GET /api/ordrestyring/materials - Materials list
  • GET /api/ordrestyring/materials/:id - Single material
  • GET /api/ordrestyring/users - Users list
  • GET /api/ordrestyring/users/:id - Single user
  • GET /api/ordrestyring/products - Products list
  • GET /api/ordrestyring/settings - Settings
  • GET /api/ordrestyring/case-statuses - Case statuses
  • GET /api/ordrestyring/offer-statuses - Offer statuses

Import/Statistics

  • POST /api/ordrestyring/import - Import data
  • GET /api/ordrestyring/statistics - Statistics
  • GET /api/ordrestyring/quotes - Quotes list

🎯 Migration Summary

Frontend Integration Points (Active Usage)

  1. FinalReview.js - Submit quote → GraphQL
  2. Calendar - Hours data → GraphQL (not actively used yet)
  3. ⚠️ LaborInput.js - Work breakdown → REST v2 (needs migration)

Priority Order

  1. DONE: Offers (FinalReview) - Most critical user flow
  2. DONE: Calendar/Hours - Data access layer
  3. ⚠️ NEXT: Work Breakdown (LaborInput) - Active user feature
  4. 🔜 Later: Cases/Customers (if needed for future features)
  5. 🔜 Optional: Legacy endpoints cleanup

Files Modified

  • backend/src/services/graphqlClient.js - GraphQL client
  • backend/src/graphql/mutations/createOffer.js - Offer mutations
  • backend/src/graphql/queries/hours.js - Hours queries
  • backend/src/graphql/mutations/hours.js - Hours mutations
  • backend/routes/offers.js - Offer routes
  • backend/routes/calendar.js - Calendar routes
  • unified-server.js - Route registration
  • frontend/src/components/FinalReview.js - Updated endpoint

Test Coverage

  • test_graphql_offer_creation.js - Offer creation (100%)
  • test_graphql_calendar.js - Calendar/hours (100%)
  • ⚠️ Work breakdown tests - Not yet created

🚀 Next Steps

Immediate (Critical Path)

  1. Migrate Work Breakdown (LaborInput.js):
    • Create GraphQL query for case work breakdown
    • Update LaborInput.js to use GraphQL endpoint
    • Test case number lookup flow

Short Term

  1. Create Cases/Customers queries (if needed for autocomplete):
    • Add cases search query
    • Add customers lookup query
    • Update any autocomplete components

Long Term

  1. Clean up legacy code:

    • Remove unused REST v2 endpoints
    • Remove ordrestyringService.js (or mark deprecated)
    • Archive old test scripts
    • Update documentation
  2. Add missing features:

    • Update offers after creation
    • Delete offers
    • Manage offer lines
    • Create/update hours entries

📊 Migration Progress

Overall: 2/3 critical endpoints migrated (66%)

  • Frontend integration: 2/3 (66%)
  • Backend GraphQL: 2/3 (66%)
  • Testing: 2/2 completed endpoints (100%)

Estimate: Work breakdown migration ~2 hours Total migration: ~85% complete after work breakdown