Skip to content

feat: add base service layer and Guilds migration pilot - #285

Merged
Lakes41 merged 3 commits into
Adamantine-guild:mainfrom
mishellerv:refactor/218-api-layer-guilds-pilot
Jul 27, 2026
Merged

feat: add base service layer and Guilds migration pilot#285
Lakes41 merged 3 commits into
Adamantine-guild:mainfrom
mishellerv:refactor/218-api-layer-guilds-pilot

Conversation

@mishellerv

Copy link
Copy Markdown
Contributor

Description

Introduces the base services layer for the mobile app's API/networking code
(centralized client, error normalization, retry with backoff, auth
interception) and migrates Guilds as the first feature to consume it, per
issue #218.

Linked Issue

Closes #218

Type of Change

  • 🐛 Bug fix (screen or component)
  • ✨ New feature / screen
  • 🎨 UI/UX improvement
  • 📝 Documentation update
  • 🔧 Chore / refactor / dependency update
  • 🧪 Tests only

Changes Made

  • Added a centralized API service layer (src/services/api/): shared HTTP
    client, normalized ApiError type, retry-with-backoff for transient
    failures, response parsing, and an auth interceptor (token injection,
    refresh-on-401, session invalidation on repeated auth failure).
  • Added guildsService (src/services/guilds/guildsService.ts) as the first
    feature-level service, wrapping the existing @guildpass/sdk client with
    the new error normalization/retry pattern.
  • Migrated useGuilds to consume guildsService instead of calling the SDK
    directly, preserving its public interface and the existing
    GuildNotFoundError export/behavior.
  • Adjusted session.adapter.ts / session.types.ts to support a real auth
    contract (token, refresh, invalidate, isAuthenticated) instead of a no-op
    adapter.
  • Adjusted React Query defaults (queryClient.ts) to avoid duplicating
    retries now handled by the service layer.
  • Documented a pre-existing, unrelated issue (@guildpass/sdk entry
    resolution failure in tests/api.test.ts) and refactor progress in
    docs/KNOWN_ISSUES.md.
  • Membership, Access, Notifications, and Attestation are intentionally not
    migrated in this PR — follow-up work, tracked as pending in
    docs/KNOWN_ISSUES.md.

Screenshots / Recordings

Not applicable — this PR is a backend/networking refactor with no UI changes.

iOS Android
N/A N/A

Test Evidence

Checklist

  • I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • pnpm typecheck passes — not run in this environment, please verify in CI
  • pnpm lint passes — not run in this environment, please verify in CI
  • pnpm test:run passes — all tests green — ran via vitest directly (32/32 passing); pnpm test:run itself was not executed, please confirm in CI
  • UI changes include a screenshot or screen recording — N/A, no UI changes
  • New screens handle loading, empty, and error states — N/A, no new screens
  • NativeWind (Tailwind) classes used — no StyleSheet.create for new UI without justification — N/A, no new UI
  • No native modules added that break Expo Go compatibility
  • No secrets, keys, or wallet credentials included
  • .env.example updated if new environment variables were added — N/A, no new env vars
  • Accessibility: interactive elements are keyboard-navigable and have accessibility labels — N/A, no new UI

Additional Notes

  • package-lock.json is intentionally not included in this PR, respecting the
    repository's existing decision (commit eef5905) to keep lockfiles out of
    version control.
  • Reviewers should specifically check the auth interceptor edge cases (token
    refresh failure, transient errors during retry not invalidating the
    session) and the GuildNotFoundError detection logic (covers both explicit
    404 status and legacy "not found" message matching).

@Lakes41

Lakes41 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

This PR cannot be merged automatically because it has merge conflicts.

Please update the branch with the latest base branch and resolve the conflicts.

After the conflicts are resolved and checks pass, the automation can review it again.

@Lakes41
Lakes41 merged commit 68487b8 into Adamantine-guild:main Jul 27, 2026
1 check passed
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.

Refactor API layer into a centralized service and request management architecture

2 participants