Conversation
There was a problem hiding this comment.
Pull Request Overview
Migrate GraphQL code generation to a centralized codegen.ts, add JSON-schema–driven webhook types, and update project setup for ESM, pnpm v10, and new generation scripts.
- Replaced
.graphqlrc.ymlwithcodegen.tsfor GraphQL codegen, enabling custom scalars and immutable types - Added
OrderFilterShippingMethodsWebhookhandler plus a script to generate its TypeScript types from JSON schemas - Updated
package.jsonscripts, pnpm workspace, and dependencies for ESM support, pnpm v10, and newgenerate:*commands
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Added vite-tsconfig-paths plugin to support path aliases in tests |
| src/pages/api/webhooks/order-filter-shipping-methods.ts | New sync webhook using JSON-schema types to filter shipping methods |
| src/pages/api/webhooks/order-created.ts | Adjusted import ordering and alias paths |
| src/pages/api/manifest.ts | Registered the new ORDER_FILTER_SHIPPING_METHODS webhook |
| src/order-example.tsx | Removed inline gql tag, updated import path and regeneration instructions |
| scripts/generate-app-webhooks-types.ts | Script to fetch JSON schemas and compile TypeScript types |
| pnpm-workspace.yaml | Configured onlyBuiltDependencies for pnpm v10 |
| package.json | Switched to ESM, added generate:* scripts, bumped pnpm and node engines |
| next.config.ts | Introduced basic Next.js config file with reactStrictMode |
| graphql/subscriptions/order-filter-shipping-methods.graphql | Added subscription document for filtering shipping methods |
| graphql/queries/last-order.graphql | Added query document for last order example |
| graphql/fragments/order-filter-shipping-methods.graphql | Fragment defining payload shape for shipping-methods filter |
| codegen.ts | New GraphQL Codegen config file with custom scalars |
| README.md | Documented both GraphQL and JSON-schema generation workflows |
| .graphqlrc.yml | Removed deprecated GraphQL codegen configuration |
| .github/workflows/main.yml | Broadened CI check to detect changes across all generated files |
Differences FoundExpandLicense Package MIT @apidevtools/json-schema-ref-parser MIT @esbuild/netbsd-arm64 MIT @esbuild/openbsd-arm64 MIT @graphql-codegen/add MIT @jsdevtools/ono MIT @types/lodash MIT fdir MIT globrex MIT json-schema-to-typescript MIT tinyglobby MIT tsconfck MIT tsx MIT vite-tsconfig-paths SummaryExpand
|
| const schemaUrl = | ||
| "https://raw.githubusercontent.com/saleor/saleor/main/saleor/json_schemas/OrderFilterShippingMethods.json"; |
There was a problem hiding this comment.
I don't think it's right that we hardcode that here. I will bootstrap new app from app-template, want to use OTHER json schema and I will have no idea how to do that.
Can we maybe extract these urls to some list and comment out not needed, or create any other abstraction?
| OrderFilterShippingMethodsPayloadFragment, | ||
| OrderFilterShippingMethodsSubscriptionDocument, | ||
| } from "@/generated/graphql"; | ||
| import { FilterShippingMethods } from "@/generated/json-schema/order-filter-shipping-methods"; |
There was a problem hiding this comment.
I dont think path json-schema is right. It's a detail. For the app it's typescript, so maybe let's do some types or something like this?
.graphqlrc.ymlto a newcodegen.ts. Added support for custom scalar types and immutable types.OrderFilterShippingMethodsWebhook) to handle filtering of shipping methods to showcase JSON schema generated typespackage.jsonto include new scripts for generating GraphQL types and webhook types, and upgraded dependencies to align with the latest Saleor version.