Skip to content

Conversation

@amcaplan
Copy link
Contributor

@amcaplan amcaplan commented Nov 6, 2025

WHY are these changes introduced?

This PR builds on the previous UI components by adding the API version selector, which allows users to switch between different Shopify Admin API versions. This is the fourth PR in the 8-PR migration stack.

Context: The GraphiQL console needs to support querying different versions of the Shopify Admin API (e.g., 2024-10, 2025-01, unstable). The current template-based implementation uses vanilla JavaScript event listeners and manual DOM manipulation to handle version changes. By creating a declarative React component, we can:

  • Use React's state management instead of manual DOM updates
  • Integrate seamlessly with the GraphiQL editor
  • Make version changes easier to test and track
  • Provide a consistent UI with other Polaris components

WHAT is this pull request doing?

This PR adds a single, focused component for API version selection using Shopify Polaris's Select component.

Key Changes:

ApiVersionSelector Component (src/components/ApiVersionSelector/):

  • Dropdown selector built on Polaris Select component
  • Accepts list of available versions as props
  • Controlled component pattern with value and onChange
  • Hidden label for accessibility ("API version")
  • Replaces: Vanilla JS event listener (addEventListener('change')) and manual DOM manipulation

Props Interface:

interface ApiVersionSelectorProps {
  versions: string[]      // e.g., ['2024-10', '2025-01', 'unstable']
  value: string          // Currently selected version
  onChange: (version: string) => void  // Callback when user selects new version
}

Usage Example:

<ApiVersionSelector
  versions={['2024-10', '2025-01', 'unstable']}
  value={currentVersion}
  onChange={(newVersion) => {
    // Update GraphiQL schema and re-fetch introspection
    setCurrentVersion(newVersion)
  }}
/>

Testing:

  • 94 lines of comprehensive tests
  • Tests rendering with different version lists
  • Tests selection change callbacks
  • Tests accessibility features

Files Added:

  • src/components/ApiVersionSelector/ApiVersionSelector.tsx - Component implementation
  • src/components/ApiVersionSelector/ApiVersionSelector.test.tsx - 94 lines of tests
  • src/components/ApiVersionSelector/index.ts - Barrel export

Dependencies

Builds on:

How to test your changes?

# Run component tests
pnpm --filter @shopify/graphiql-console test ApiVersionSelector.test.tsx

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

# All 94 lines of tests should pass, covering:
# - Rendering with version list
# - Version selection and onChange callbacks
# - Accessibility (hidden label)

Manual Testing:
You can test the component in the App by simulating version changes:

import {ApiVersionSelector} from './components/ApiVersionSelector'
import {useState} from 'react'

const [version, setVersion] = useState('2024-10')

<ApiVersionSelector
  versions={['2024-10', '2025-01', 'unstable']}
  value={version}
  onChange={setVersion}
/>

Measuring impact

  • n/a - this is a foundational UI component

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.33% 13670/17231
🟡 Branches 73.24% 6696/9143
🟡 Functions 79.45% 3525/4437
🟡 Lines 79.69% 12911/16201

Test suite run success

3407 tests passing in 1393 suites.

Report generated by 🧪jest coverage report action from ecb6ff8

@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch from 106240c to ece610f Compare November 6, 2025 16:53
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch 2 times, most recently from fc285da to 9607030 Compare November 6, 2025 17:27
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch from ece610f to b31bbbe Compare November 6, 2025 17:27
@amcaplan amcaplan changed the base branch from 11-06-feat_graphiql_add_base_ui_components to graphite-base/6581 November 6, 2025 21:20
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch from 9607030 to b09054f Compare November 6, 2025 21:21
@amcaplan amcaplan changed the base branch from graphite-base/6581 to 11-06-feat_graphiql_add_base_ui_components November 6, 2025 21:21
@amcaplan amcaplan changed the base branch from 11-06-feat_graphiql_add_base_ui_components to graphite-base/6581 November 6, 2025 21:28
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch from b09054f to 4af8d43 Compare November 6, 2025 21:28
@amcaplan amcaplan changed the base branch from graphite-base/6581 to 11-06-feat_graphiql_add_base_ui_components November 6, 2025 21:28
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch from 4af8d43 to c2551ad Compare November 6, 2025 21:44
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch 2 times, most recently from 7b22de0 to d2a007d Compare November 6, 2025 21:49
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch 2 times, most recently from 6dedd3f to cc588d6 Compare November 6, 2025 22:14
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch from d2a007d to f3f94ef Compare November 6, 2025 22:14
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch from cc588d6 to b5d1cb1 Compare November 6, 2025 22:27
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch from f3f94ef to e4e87e9 Compare November 6, 2025 22:27
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch from b5d1cb1 to b2f9616 Compare November 6, 2025 22:46
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch from e4e87e9 to db5e515 Compare November 6, 2025 22:46
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch from b2f9616 to b20c543 Compare November 6, 2025 22:55
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch 2 times, most recently from 0cd0b46 to 45c17b5 Compare November 6, 2025 23:17
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch 2 times, most recently from 7f1b051 to ab008f1 Compare November 6, 2025 23:21
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch from 45c17b5 to d34bd65 Compare November 6, 2025 23:21
Adds dropdown component for selecting Admin API version.

- Add ApiVersionSelector component using Polaris Select
- Support for version list and change callbacks
- Include comprehensive tests (94 lines)

All component tests pass
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_api_version_selector_component branch from ab008f1 to ecb6ff8 Compare November 6, 2025 23:34
@amcaplan amcaplan force-pushed the 11-06-feat_graphiql_add_base_ui_components branch from d34bd65 to cb351dd 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