chore: revert GraphQL builder from 2.x to 1.x - #690
Conversation
Builder 2.x introduced strict variable coercion that broke ~9,300 production requests/day from third-party apps that cannot be updated. The most common failures (from errors.csv): - quantity: 1 (Int) where schema expected String → 6,467 errors - seller: 1 (Int) where schema expected String → 1,264 errors - category id: "1000240" (String) where schema expected Int → 1,147 errors - geoCoordinates: [float, float] where schema expected [String] → 433 errors Reverting to graphql@1.x restores the lenient coercion behaviour of the previous runtime while keeping the node@7.x upgrade (Node 20). The four custom directive declarations added for node@7.x SDL validation (withSegment, withOrderFormId, withCurrentProfile, toVtexAssets) are intentionally kept — they are a node@7.x runtime requirement, not a graphql@2.x one. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
|
@mendescamara, o GraphQL 2.x é mais rígido com tipos e acabou afetando alguns merchants que enviam valores no formato errado. A ideia aqui é voltar pro builder 1.x por enquanto e tratar esses casos antes de subir de novo pro 2.x em outro PR. |
vmourac-vtex
left a comment
There was a problem hiding this comment.
LGTM
Nice to have validated against all regressions!
|
Your PR has been merged! App is being published. 🚀 After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:
After that your app will be updated on all accounts. For more information on the deployment process check the docs. 📖 |
## What problem is this solving? Builder `2.x` requires `@auth` on every query and mutation. The previous upgrade attempt (#687) was reverted in #690 due to strict variable coercion errors — **not** because of this requirement. That root cause was fixed by the `@coerce` directive in #692, so the upgrade is safe to land now. ## What changed? - `manifest.json`: `"graphql": "1.x"` → `"graphql": "2.x"` - `graphql/schema.graphql`: `@auth(scope: PUBLIC)` added to all queries and mutations; `scalar Upload` declaration added All fields use `scope: PUBLIC`, preserving the same public-by-default behaviour as `1.x`. ## How to test it? Run `./test-errors-regression.sh` against a linked workspace — all 14 regression cases should pass. ## Related Re-introduces the GraphQL builder portion of #687. Depends on the coercion fix from #692. Made with Cursor Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com>
What problem is this solving?
GraphQL builder 2.x introduced strict variable coercion via a newer
graphql-jsruntime. Third-party store apps that cannot be updated are sending variables with types that don't exactly match the schema declarations (e.g.quantity: 1as an integer where the schema expectsString,seller: 1as integer,geoCoordinates: [float, float]where[String]is expected, and category/documentidas a string whereIntis expected).These mismatches cause hard
GraphQLErrorvalidation failures before resolvers are even reached. From the collected error logs, we identified the following distribution:quantity: 1(Int) → expectedStringseller: 1(Int) → expectedStringcategory id: "20"(String) → expectedIntgeoCoordinates: [float]→ expected[String]Reverting to
graphql@1.xrestores the lenient coercion behaviour of the previous runtime. Thenode@7.xupgrade (Node 20,@vtex/apiv7) introduced in #687 is kept — only the GraphQL builder version is reverted.How to test it?
Regression script (
test-errors-regression.shin repo root) sends the exact queries and variable shapes extracted fromerrors.csvand asserts HTTP 200 with noerrorsblock.Results against the linked workspace:
Workspace
Screenshots or example usage:
Before (
graphql@2.x) — error from production logs:After (
graphql@1.x) — same request:Describe alternatives you've considered, if any.
FlexibleInt,FlexibleString, etc.): Implementing custom scalars that accept both types was explored. However, this changes the type names visible in the SDL, which breaks any client that declares variables with the original types (e.g.$id: Intfails against an argument now typedFlexibleInt). Since third-party apps cannot be updated, this approach would trade one class of breakage for another.Related to / Depends on
Reverts the GraphQL builder portion of #687.
Node builder upgrade (
node@4.x→node@7.x) from #687 is not reverted.Made with Cursor