Skip to content

feat(wake): use checkoutUrl as GraphQL storefront endpoint - #1653

Merged
guitavano merged 3 commits into
mainfrom
guitavano/wake-api-integration
Aug 6, 2026
Merged

feat(wake): use checkoutUrl as GraphQL storefront endpoint#1653
guitavano merged 3 commits into
mainfrom
guitavano/wake-api-integration

Conversation

@guitavano

@guitavano guitavano commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What

Changes the Wake Storefront GraphQL client to point at ${checkoutUrl}/graphql instead of the hardcoded https://storefront-api.fbits.net/graphql.

-    endpoint: "https://storefront-api.fbits.net/graphql",
+    endpoint: `${checkoutUrl}/graphql`,

Why

The Storefront GraphQL endpoint is now derived from the account's configured checkoutUrl (e.g. https://checkout.erploja2.com.br), so the GraphQL API is served from the same domain as the rest of the Wake integration instead of the shared storefront-api.fbits.net host.

Notes

  • checkoutUrl is already a required app prop (wake/mod.ts), so no new configuration is needed.
  • The TCS-Access-Token auth header (Storefront Token) is unchanged.

🤖 Generated with Claude Code


Summary by cubic

Switch the Storefront GraphQL client to ${checkoutUrl}/graphql, normalized with new URL to prevent double slashes, and fall back to https://storefront-api.fbits.net/graphql when checkoutUrl is empty. No config changes; the TCS-Access-Token header stays the same.

Written for commit 31ed376. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Updated the Wake storefront GraphQL connection to use the configured checkout URL, improving compatibility with custom storefront configurations.

Point the Storefront GraphQL client to ${checkoutUrl}/graphql instead of
the hardcoded https://storefront-api.fbits.net/graphql.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.160.1 update
  • 🎉 for Minor 0.161.0 update
  • 🚀 for Major 1.0.0 update

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Wake storefront GraphQL endpoint now resolves /graphql against checkoutUrl. When checkoutUrl is absent, it uses the account-based checkout domain.

Changes

Wake GraphQL endpoint

Layer / File(s) Summary
Configure the storefront GraphQL endpoint
wake/mod.ts
The client builds the GraphQL endpoint from checkoutUrl or the account-based checkout domain.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: using checkoutUrl for the Wake GraphQL storefront endpoint.
Description check ✅ Passed The description clearly explains the change, rationale, fallback behavior, and unchanged authentication, but omits the template's issue, Loom, and demonstration links.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch guitavano/wake-api-integration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread wake/mod.ts Outdated
Comment thread wake/mod.ts Outdated
Address cubic review: use new URL("/graphql", ...) to avoid a
double-slash when checkoutUrl has a trailing slash, and fall back to
https://${account}.checkout.fbits.store when checkoutUrl is empty,
matching the checkoutApi client.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="wake/mod.ts">

<violation number="1" location="wake/mod.ts:114">
P2: The new fallback doesn't handle the empty-string case it's meant to cover. `checkoutUrl ?? ...` only guards null/undefined, but checkoutUrl is a required string and the realistic misconfig is an empty string, which flows into `new URL("/graphql", "")` and throws an uncaught TypeError during app init (both here and in createGraphqlClient's own `new URL(endpoint)`), breaking the storefront instead of degrading to the fallback. Use a truthiness check (e.g. `checkoutUrl.trim() || ...`) if the intent is to fall back when checkoutUrl is unset/empty.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread wake/mod.ts Outdated
endpoint: "https://storefront-api.fbits.net/graphql",
endpoint: new URL(
"/graphql",
checkoutUrl ?? `https://${account}.checkout.fbits.store`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new fallback doesn't handle the empty-string case it's meant to cover. checkoutUrl ?? ... only guards null/undefined, but checkoutUrl is a required string and the realistic misconfig is an empty string, which flows into new URL("/graphql", "") and throws an uncaught TypeError during app init (both here and in createGraphqlClient's own new URL(endpoint)), breaking the storefront instead of degrading to the fallback. Use a truthiness check (e.g. checkoutUrl.trim() || ...) if the intent is to fall back when checkoutUrl is unset/empty.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wake/mod.ts, line 114:

<comment>The new fallback doesn't handle the empty-string case it's meant to cover. `checkoutUrl ?? ...` only guards null/undefined, but checkoutUrl is a required string and the realistic misconfig is an empty string, which flows into `new URL("/graphql", "")` and throws an uncaught TypeError during app init (both here and in createGraphqlClient's own `new URL(endpoint)`), breaking the storefront instead of degrading to the fallback. Use a truthiness check (e.g. `checkoutUrl.trim() || ...`) if the intent is to fall back when checkoutUrl is unset/empty.</comment>

<file context>
@@ -109,7 +109,11 @@ For help: https://wakecommerce.readme.io/docs/storefront-api-criacao-e-autentica
-    endpoint: `${checkoutUrl}/graphql`,
+    endpoint: new URL(
+      "/graphql",
+      checkoutUrl ?? `https://${account}.checkout.fbits.store`,
+    )
+      .href,
</file context>
Suggested change
checkoutUrl ?? `https://${account}.checkout.fbits.store`,
checkoutUrl?.trim() || `https://${account}.checkout.fbits.store`,

Preserve the previous default host when checkoutUrl is empty instead of
pointing at the checkout store.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@guitavano
guitavano merged commit 74c4b99 into main Aug 6, 2026
3 checks passed
@guitavano
guitavano deleted the guitavano/wake-api-integration branch August 6, 2026 12:53
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