ALFMOB-330: Set up BFF GraphQL networking and schema sync workflow#72
ALFMOB-330: Set up BFF GraphQL networking and schema sync workflow#72khoinguyen-mindera wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Sets up a BFF-owned GraphQL workflow in Alfie iOS by consolidating the schema into a single committed file, adding a schema sync script, and updating documentation and local endpoint defaults to support a “sync schema → run Apollo codegen” loop.
Changes:
- Aligns the dev API endpoint to the BFF default local port (
localhost:3000) and replaces PreProd/Prod URLs with explicit TBD placeholders. - Adds
sync-bff-schema.shand makes Apollo CLI install non-interactive via SwiftPM--allow-network-connections all. - Replaces multiple hand-maintained
schema-*.graphqlsfragments with a single committedschema.graphqls, and updates docs to match the new workflow.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates the GraphQL section to point to the new workflow doc and committed schema location. |
| Docs/GraphQL.md | Documents local BFF usage, schema sync, and query/codegen workflow. |
| Alfie/scripts/sync-bff-schema.sh | Adds a script to update the committed schema from the Alfie-BFF repo and run codegen. |
| Alfie/scripts/run-apollo-codegen.sh | Makes Apollo CLI install non-interactive by pre-allowing network connections. |
| Alfie/AlfieKit/Sources/BFFGraph/CodeGen/Schema/schema.graphqls | Introduces the single, synced schema file used by Apollo codegen. |
| Alfie/AlfieKit/Sources/BFFGraph/CodeGen/Schema/schema-search.graphqls | Removes the previous hand-curated schema fragment. |
| Alfie/AlfieKit/Sources/BFFGraph/CodeGen/Schema/schema-products.graphqls | Removes the previous hand-curated schema fragment. |
| Alfie/AlfieKit/Sources/BFFGraph/CodeGen/Schema/schema-navigation.graphqls | Removes the previous hand-curated schema fragment. |
| Alfie/AlfieKit/Sources/BFFGraph/CodeGen/Schema/schema-brand.graphqls | Removes the previous hand-curated schema fragment. |
| Alfie/AlfieKit/Sources/BFFGraph/CodeGen/Schema/schema-base.graphqls | Removes the previous hand-curated base schema fragment. |
| Alfie/Alfie/Service/ApiEndpointService.swift | Updates default endpoints (dev port alignment + TBD placeholders). |
Comments suppressed due to low confidence (1)
Alfie/Alfie/Service/ApiEndpointService.swift:45
devnow points tolocalhost:3000, but the committed GraphQL operations / generated API still target the older schema (product,productListing,suggestion, etc.). Given the new synced schema defines different query fields, Debug builds will likely fail against a BFF running on :3000 until operations +BFFClientServiceare migrated to the new schema (or the dev endpoint remains on the legacy port during the transition).
// Local dev: aligned with the BFF default port. BFFClientService appends `graphql` /
// `config/webviews` to this base, so it must stay an origin root (trailing slash, no path).
case dev = "http://localhost:3000/"
// TODO: Real PreProd/Prod BFF environment URLs are not provisioned yet — these are
| type Query { | ||
| productDetails(handle: String!, platform: String!, productMetafields: [MetafieldIdentifierInput!], variantMetafields: [MetafieldIdentifierInput!]): OmniProduct | ||
| productList(after: String, collectionHandle: String!, filters: ProductFilterInput, limit: Int! = 25, platform: String, sort: ProductSortEnum! = NEWEST): ProductListResponse! | ||
| searchProducts(after: String, filters: ProductFilterInput, limit: Int! = 10, platform: String, searchTerm: String!, sort: ProductSortEnum! = NEWEST): ProductListResponse! | ||
| } |
amccall-mindera
left a comment
There was a problem hiding this comment.
Reviewed in the context of this being a setup ticket for an epic migrating mock backend → BFF, where the goal is keeping the repo compilable while subsequent tickets migrate queries/converters per feature. Generated Swift in BFFGraph/API/ is committed, so Swift builds stay green even though committed .graphql operations no longer match the new schema — re-running codegen will fail until those queries are migrated, which is expected for this stage.
A handful of smaller things below.
| // explicit TBD placeholders. Replace once the real environments exist. | ||
| case preProd = "https://preprod.bff.tbd.invalid/" | ||
| case prod = "https://prod.bff.tbd.invalid/" | ||
| case custom = "https://api-preview-000.localhost:3000/" |
There was a problem hiding this comment.
Was the api-preview-000.localhost host intentional, or a leftover from the old :4000 placeholder? For a Debug-menu custom-endpoint prefill, a plain http://localhost:3000/ (or empty) would be less misleading.
| type VariantOption { | ||
| name: String! | ||
| value: String! | ||
| } No newline at end of file |
There was a problem hiding this comment.
Minor: file ends without a trailing newline (BFF's src/schema.gql doesn't terminate). The sync script could printf '\n' >> after the copy to normalise this on every sync.
Ticket
ALFMOB-330
Summary
localhost:3000); replace placeholder PreProd/Prod URLs with explicitTBDmarkers.Alfie/scripts/sync-bff-schema.sh— pulls latest Alfie-BFF, copies itssrc/schema.gqlintoBFFGraph/CodeGen/Schema/schema.graphqls, runs Apollo codegen. Read-only with respect to the BFF repo.schema-*.graphqlsfiles with the single BFF-syncedschema.graphqls.--allow-network-connections allinrun-apollo-codegen.sh).Docs/GraphQL.md(run local BFF, point the app, sync schema, regenerate types); trim the stale GraphQL section inREADME.mdto a pointer.Screenshot