Skip to content

Conversation

@amcaplan
Copy link
Contributor

@amcaplan amcaplan commented Nov 6, 2025

WHY are these changes introduced?

This PR brings together all the components from previous PRs into a complete, functional GraphiQL section with responsive layout. This is the seventh PR in the 8-PR migration stack.

Context: All the building blocks are now in place (editor, components, hooks, types, validation). This PR integrates everything into a cohesive user interface that:

  • Monitors server health in real-time
  • Allows API version switching
  • Shows connection status and store information
  • Provides the full GraphiQL editing experience
  • Adapts to different screen sizes with responsive design

WHAT is this pull request doing?

This PR creates the main GraphiQLSection component that integrates all previous components into a complete application with responsive layout.

Key Changes:

1. GraphiQLSection Component (src/sections/GraphiQL/):
Main container that orchestrates all GraphiQL functionality.

Component Structure:

┌─────────────────────────────────────────────┐
│ Error Banner (sticky, shown when disconnected) │
├─────────────────────────────────────────────┤
│ Header (responsive grid layout)             │
│ ┌───────────────┬─────────────────────────┐ │
│ │ Left Section  │ Right Section          │ │
│ │ - Status Badge│ - Scopes Note          │ │
│ │ - API Version │                        │ │
│ │ - Link Pills  │                        │ │
│ └───────────────┴─────────────────────────┘ │
├─────────────────────────────────────────────┤
│ GraphiQL Editor (full height)               │
│ - Query tabs                                │
│ - Monaco syntax highlighting                │
│ - Docs explorer                             │
│ - Results panel                             │
└─────────────────────────────────────────────┘

2. Configuration Management:

function getConfig(): GraphiQLConfig {
  const fallbackConfig = {
    baseUrl: import.meta.env.VITE_GRAPHIQL_BASE_URL ?? 'http://localhost:3457',
    apiVersion: '2024-10',
    apiVersions: ['2024-01', '2024-04', '2024-07', '2024-10', 'unstable'],
    appName: 'Development App',
    appUrl: 'http://localhost:3000',
    storeFqdn: 'test-store.myshopify.com',
  }
  
  // SECURITY: Validate window.__GRAPHIQL_CONFIG__ before use
  if (window.__GRAPHIQL_CONFIG__) {
    return validateConfig(window.__GRAPHIQL_CONFIG__, fallbackConfig)
  }
  
  return fallbackConfig
}
  • Gets config from window.__GRAPHIQL_CONFIG__ (injected by server)
  • Falls back to env vars or defaults for development
  • Security: Uses validateConfig to prevent XSS attacks
  • Memoized to avoid re-computation on every render

3. State Management:

  • selectedVersion - Current API version (local state)
  • status - Server health and app info (from useServerStatus hook)
  • Config is immutable after initial load

4. Responsive Layout (GraphiQL.module.scss):

  • Uses CSS Grid for flexible layout
  • 127 lines of responsive styling

Breakpoints:

  • < 650px: Very narrow screens - minimal link text
  • < 1150px: Narrow screens - reduced link width
  • < 1550px: Medium screens - hide section labels
  • ≥ 1081px: Wide screens - two-column header layout

Responsive Behavior:

// Single column on narrow screens
.Header {
  grid-template-columns: 1fr;
}

// Two-column layout on wide screens (≥1081px)
@media (min-width: 1081px) {
  .Header {
    grid-template-columns: 7fr 5fr;  // Left heavy
  }
  .RightSection {
    justify-self: end;  // Right-align scopes note
  }
}

// Hide labels on medium screens (≤1550px)
@media (max-width: 1550px) {
  .top-bar-section-title {  // "Status:", "API version:", etc.
    display: none;
  }
}

5. Component Integration:
All components work together seamlessly:

  • StatusBadge shows real-time connection status
  • ErrorBanner appears when server disconnects (sticky positioning)
  • ApiVersionSelector triggers re-fetch when version changes
  • LinkPills show store/app links from server status
  • GraphiQLEditor receives config and selected version
  • useServerStatus provides live server/app state

6. App.tsx Update:

// Before: Minimal placeholder
export function App() {
  return <div>App Placeholder</div>
}

// After: Complete GraphiQL application
export function App() {
  return <GraphiQLSection />
}

Testing:

  • 219 lines of integration tests
  • Tests component rendering
  • Tests responsive behavior
  • Tests state management
  • Tests error scenarios
  • All 89 tests pass across the entire package

Files Added/Modified:

  • src/sections/GraphiQL/GraphiQL.tsx - Main section component (92 lines)
  • src/sections/GraphiQL/GraphiQL.module.scss - Responsive styles (127 lines)
  • src/sections/GraphiQL/GraphiQL.test.tsx - Integration tests (219 lines)
  • src/sections/GraphiQL/index.ts - Barrel export
  • src/App.tsx - Updated to use GraphiQLSection

Dependencies

Builds on ALL previous PRs:

Result: Complete, functional graphiql-console package! ✅

How to test your changes?

# Run all tests (89 tests)
pnpm --filter @shopify/graphiql-console test

# Type check
pnpm --filter @shopify/graphiql-console tsc --noEmit

# Build the package
pnpm --filter @shopify/graphiql-console build

# Dev mode (requires server running at baseUrl)
pnpm --filter @shopify/graphiql-console dev

Manual Testing - Development Mode:

  1. Start the package in dev mode:
    cd packages/graphiql-console
    pnpm dev
  2. Open http://localhost:5173
  3. You should see:
    • Status badge (may show "Disconnected" if no server)
    • API version selector
    • GraphiQL editor with welcome tab
    • Responsive layout that adapts as you resize the browser

Manual Testing - With Server:

  1. Start the CLI dev server: dev server
  2. The server should inject config via window.__GRAPHIQL_CONFIG__
  3. You should see:
    • ✅ "Running" status
    • Store and app link pills
    • Working GraphQL queries
    • Real-time server health monitoring

Responsive Testing:

  • Resize browser to different widths
  • Verify labels hide at 1550px
  • Verify two-column layout at 1081px
  • Verify link text truncates at narrow widths

Measuring impact

  • n/a - this is the integration layer bringing all components together

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

amcaplan commented Nov 6, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 79.38% 13748/17320
🟡 Branches 73.29% 6729/9181
🟡 Functions 79.4% 3549/4470
🟡 Lines 79.74% 12979/16277

Test suite run success

3447 tests passing in 1401 suites.

Report generated by 🧪jest coverage report action from 0de0e5b

@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from 0c3ce5a to ada77f5 Compare November 6, 2025 16:53
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_data_fetching_hooks branch 2 times, most recently from 3b8bbcc to 2e1b3ee Compare November 6, 2025 17:27
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from ada77f5 to 0de0e5b Compare November 6, 2025 17:27
@amcaplan amcaplan changed the base branch from 11-06-feat_graphiql_add_data_fetching_hooks to graphite-base/6584 November 6, 2025 21:21
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from 0de0e5b to dfabb65 Compare November 6, 2025 21:22
@amcaplan amcaplan changed the base branch from graphite-base/6584 to 11-06-feat_graphiql_add_data_fetching_hooks November 6, 2025 21:22
@amcaplan amcaplan changed the base branch from 11-06-feat_graphiql_add_data_fetching_hooks to graphite-base/6584 November 6, 2025 21:28
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from dfabb65 to af92c30 Compare November 6, 2025 21:29
@amcaplan amcaplan changed the base branch from graphite-base/6584 to 11-06-feat_graphiql_add_data_fetching_hooks November 6, 2025 21:29
@amcaplan amcaplan changed the base branch from 11-06-feat_graphiql_add_data_fetching_hooks to graphite-base/6584 November 6, 2025 22:14
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from af92c30 to de0599e Compare November 6, 2025 22:14
@amcaplan amcaplan changed the base branch from graphite-base/6584 to 11-06-feat_graphiql_add_data_fetching_hooks November 6, 2025 22:14
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_data_fetching_hooks branch from a6fca5f to f6b80c1 Compare November 6, 2025 22:27
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from de0599e to e5b4e41 Compare November 6, 2025 22:27
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_data_fetching_hooks branch from f6b80c1 to f574269 Compare November 6, 2025 22:46
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch 2 times, most recently from ffeaf36 to 2fed8fb Compare November 6, 2025 22:55
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_data_fetching_hooks branch from f574269 to 1e4b9d5 Compare November 6, 2025 22:55
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch 3 times, most recently from 48047fb to 16851d0 Compare November 6, 2025 23:17
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_data_fetching_hooks branch 2 times, most recently from 33e19e2 to fa9758f Compare November 6, 2025 23:21
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from 16851d0 to 530b9a5 Compare November 6, 2025 23:21
Integrates all components into the main GraphiQL section with responsive layout.

- Add main GraphiQL section with header and editor
- Implement responsive layout with CSS Grid
- Add API version selector, status badge, links, scopes note
- Update App to use complete GraphiQL section
- Include integration tests (219+ lines)

Complete graphiql-console package is now functional
All tests pass (89/89)
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_complete_graphiql_section_and_app_integration branch from 530b9a5 to 8708c64 Compare November 6, 2025 23:34
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_data_fetching_hooks branch from fa9758f to eeb9b92 Compare November 6, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant