Files
tilbudgivern/archive/docs/GRAPHQL_MIGRATION_INDEX.md
T
2025-10-30 18:28:58 +00:00

10 KiB
Raw Blame History

📋 GraphQL Migration Documentation Index

Last Updated: October 23, 2025


🎯 Quick Navigation

🚀 Start Here

→ MIGRATION_QUICK_START.md - Step-by-step guide til at implementere createOffer (~1.5 timer)

📊 Complete Overview

→ TODO_ANALYZE_AND_MIGRATE_ORDRESTYRING_TO_GRAPHQL.md - Fuld 4-ugers migrationsplan

🔍 Current State Analysis

→ ORDRESTYRING_API_INVENTORY.md - Komplet oversigt over alle nuværende API endpoints

📚 Background Information

→ TODO_MIGRATE_TO_GRAPHQL_API.md - Generel GraphQL migration guide

→ apitest/API_INTEGRATION_GUIDE.md - 565 GraphQL scripts dokumentation


📄 Document Overview

1. MIGRATION_QUICK_START.md (8.1 KB)

Purpose: Kom i gang med FinalReview createOffer implementation
Audience: Developers who want to start immediately
Time to Complete: 1.5 hours
Status: ✅ Ready to use

What's Inside:

  • Problem beskrivelse (FinalReview endpoint virker ikke)
  • Working GraphQL example fra apitest
  • 7-step implementation guide
  • Code examples (copy-paste ready)
  • Debugging tips
  • Success criteria

When to Use: Når du skal implementere "Opret Tilbud" funktionaliteten NU


2. TODO_ANALYZE_AND_MIGRATE_ORDRESTYRING_TO_GRAPHQL.md (28 KB)

Purpose: Komplet migration plan for hele projektet
Audience: Technical lead, project managers, developers
Time Scope: 3-4 uger
Status: 🔍 Planning phase

What's Inside:

  • Fase 1: Analyse af nuværende API brug (Uge 1)
  • Fase 2: GraphQL Setup & Configuration (Uge 1-2)
  • Fase 3: Critical Endpoint Migration (Uge 2) - INCLUDES FinalReview createOffer
  • Fase 4: Service Layer Refactoring (Uge 2-3)
  • Fase 5: Cleanup & Optimization (Uge 3)
  • Fase 6: Testing & Validation (Uge 3-4)
  • Fase 7: Deployment & Monitoring (Uge 4)
  • Complete risk assessment
  • Rollback procedures
  • Success criteria

When to Use: Når du planlægger den fulde migration eller skal estimere tidsplan


3. ORDRESTYRING_API_INVENTORY.md (17 KB)

Purpose: Detaljeret inventory af alle nuværende Ordrestyring API kald
Audience: Developers, auditors
Status: 🔍 Analysis document

What's Inside:

  • Complete file-by-file analysis af alle API kald
  • Backend services (3 files):
    • ordrestyringService.js (790 lines) - MIXED REST/GraphQL
    • ordrestyringSyncService.js - REST v2 only
    • enhancedOrderDataService.js - REST v2 only
  • API routes analysis
  • Frontend components (2 files):
    • FinalReview.js - CRITICAL - non-existent endpoint
    • LaborInput.js - REST v2
  • Unified server calendar/hours endpoints
  • Priority matrix (Critical/High/Medium/Low)
  • GraphQL equivalents for each endpoint
  • Estimated migration effort per endpoint

When to Use: Når du skal forstå præcis hvilke endpoints der bruges hvor


4. TODO_MIGRATE_TO_GRAPHQL_API.md (15 KB)

Purpose: Generel GraphQL migration guide (tidligere oprettet)
Audience: Developers new to GraphQL
Status: ℹ️ Background information

What's Inside:

  • GraphQL benefits
  • General migration strategy
  • Code examples (React + Node.js)
  • Testing strategy
  • Security checklist
  • Performance considerations

When to Use: Som reference når du lærer om GraphQL eller skal uddanne teamet


5. apitest/API_INTEGRATION_GUIDE.md (See apitest folder)

Purpose: Documentation for 565 available GraphQL scripts
Audience: All developers
Status: ✅ Complete reference

What's Inside:

  • 255 Query scripts (safe, read-only)
  • 310 Mutation scripts (write operations)
  • 144 Output examples
  • Integration examples
  • Safety levels (Green/Yellow/Red)
  • Complete endpoint catalog

When to Use: Når du skal finde den præcise GraphQL query/mutation for et endpoint


For Immediate Implementation (FinalReview)

  1. MIGRATION_QUICK_START.md ← Start here!
  2. apitest/examples/curl_create_offer.sh ← Working example
  3. ORDRESTYRING_API_INVENTORY.md (Section 3.1) ← Context

For Planning Complete Migration

  1. ORDRESTYRING_API_INVENTORY.md ← Understand current state
  2. TODO_ANALYZE_AND_MIGRATE_ORDRESTYRING_TO_GRAPHQL.md ← Full plan
  3. apitest/API_INTEGRATION_GUIDE.md ← Available GraphQL resources

For Learning GraphQL

  1. TODO_MIGRATE_TO_GRAPHQL_API.md ← General concepts
  2. apitest/API_INTEGRATION_GUIDE.md ← Practical examples
  3. MIGRATION_QUICK_START.md ← Hands-on implementation

📊 Current Status Summary

✅ Completed

  • ✅ 565/566 GraphQL scripts dokumenteret (99.8% coverage)
  • ✅ Complete API inventory done
  • ✅ Migration plan created
  • ✅ Quick start guide written
  • ✅ 25,050 Bygma products mapped to categories (74.5%)

🔄 In Progress

  • 🔄 GraphQL client setup (ready to implement)
  • 🔄 FinalReview createOffer endpoint (ready to code)

⏳ Not Started

  • ⏳ Calendar/hours endpoint migration
  • ⏳ Work breakdown migration
  • ⏳ Service layer refactoring
  • ⏳ Complete testing suite
  • ⏳ Production deployment

🚀 Next Immediate Actions

This Week

  1. ✅ Install GraphQL client (npm install graphql-request graphql)
  2. ✅ Implement createOffer (follow MIGRATION_QUICK_START.md)
  3. ✅ Test in FinalReview (verify tilbud oprettes i Ordrestyring)

Next Week

  1. ⏳ Migrate calendar endpoints
  2. ⏳ Migrate hours endpoints
  3. ⏳ Migrate work breakdown

Week 3-4

  1. ⏳ Refactor services
  2. ⏳ Complete testing
  3. ⏳ Deploy to production

🎓 Key Concepts

GraphQL vs REST

REST v2 (Current):

// Multiple endpoints
GET /cases
GET /cases/:id
GET /cases/:id/activities
GET /cases/:id/materials

GraphQL (New):

// Single endpoint, flexible queries
POST /graphql
{
  query GetCase($id: Int!) {
    case(id: $id) {
      id
      activities { ... }
      materials { ... }
    }
  }
}

API Endpoints

  • REST v1 (Deprecated): https://api.ordrestyring.dk
  • REST v2 (To Replace): https://v2.api.ordrestyring.dk
  • GraphQL Production: https://graphql.ordrestyring.dk/graphql
  • GraphQL Beta (Current): https://beta7-api.ordrestyring.dk/graphql

Authentication

// REST v2
auth: { username: apiToken, password: 'x' }

// GraphQL
headers: { 'Authorization': `Bearer ${apiToken}` }

📞 Support & Resources

Documentation

  • Main Docs: This folder
  • API Scripts: /mnt/HC_Volume_103713257/tilbudgivern/apitest/examples/
  • API Outputs: /mnt/HC_Volume_103713257/tilbudgivern/apitest/outputs/

Helpful Commands

# Test GraphQL directly
cd /mnt/HC_Volume_103713257/tilbudgivern/apitest/examples
./curl_create_offer.sh

# View script help
./mutation_create_offer.sh --help

# List all offer-related scripts
ls -1 *offer*.sh

External Resources


🔍 File Locations Reference

Documentation

/mnt/HC_Volume_103713257/tilbudgivern/
├── MIGRATION_QUICK_START.md                          ← Start here
├── TODO_ANALYZE_AND_MIGRATE_ORDRESTYRING_TO_GRAPHQL.md  ← Full plan
├── ORDRESTYRING_API_INVENTORY.md                     ← Current state
├── TODO_MIGRATE_TO_GRAPHQL_API.md                    ← General guide
└── apitest/
    ├── API_INTEGRATION_GUIDE.md                      ← 565 scripts
    └── examples/
        ├── curl_*.sh                                 ← 255 queries
        └── mutation_*.sh                             ← 310 mutations

Code to Modify

Backend:
├── backend/src/services/
│   ├── ordrestyringService.js                        ← Main service
│   ├── ordrestyringSyncService.js                    ← Sync service
│   └── enhancedOrderDataService.js                   ← Enhanced data
├── backend/routes/
│   ├── ordrestyring.js                               ← API routes
│   └── offers.js                                     ← NEW - createOffer
└── unified-server.js                                 ← Calendar/hours

Frontend:
└── frontend/src/components/
    ├── FinalReview.js                                ← CRITICAL
    └── LaborInput.js                                 ← Work breakdown

✅ Migration Checklist

Use this checklist to track progress:

Phase 1: Critical (Week 1-2)

  • Install GraphQL client (graphql-request)
  • Create GraphQL client wrapper
  • Implement createOffer mutation
  • Update FinalReview.js
  • Test offer creation end-to-end
  • Verify in Ordrestyring system

Phase 2: Core Endpoints (Week 2)

  • Migrate calendar endpoint
  • Migrate hours endpoint
  • Migrate planned time endpoint
  • Migrate work breakdown
  • Update LaborInput.js

Phase 3: Services (Week 2-3)

  • Refactor ordrestyringService.js
  • Merge ordrestyringSyncService.js
  • Merge enhancedOrderDataService.js
  • Remove REST v1 code
  • Remove REST v2 code

Phase 4: Cleanup (Week 3)

  • Archive test scripts
  • Update .env configuration
  • Remove deprecated endpoints
  • Update documentation

Phase 5: Testing (Week 3-4)

  • Unit tests for GraphQL queries
  • Integration tests
  • E2E tests
  • Performance testing

Phase 6: Deployment (Week 4)

  • Deploy to staging
  • User acceptance testing
  • Deploy to production (staged)
  • Monitor and optimize

🎯 Success Metrics

Functionality

  • ✅ All endpoints migrated to GraphQL
  • ✅ Zero REST v1/v2 endpoints remain
  • ✅ FinalReview creates real offers
  • ✅ All CRUD operations work

Quality

  • ✅ Test coverage > 80%
  • ✅ Error rate < 0.5%
  • ✅ Response times < REST v2
  • ✅ Zero data corruption

Documentation

  • ✅ All APIs documented
  • ✅ Team trained
  • ✅ Runbooks created

Created: October 23, 2025
Last Updated: October 23, 2025
Status: 📚 Documentation Complete - Ready for Implementation
Next Step: Follow MIGRATION_QUICK_START.md to implement createOffer