@graphcommerce/graphql-mesh 10.1.0-canary.31 → 10.1.0-canary.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.1.0-canary.32
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2644](https://github.com/graphcommerce-org/graphcommerce/pull/2644) [`c4ca56a`](https://github.com/graphcommerce-org/graphcommerce/commit/c4ca56a08915d918f78339ecddcc418dfc26857d) - Fix GraphQL multipart uploads (`Upload` scalar) through the Mesh. Next.js' pages-router bodyParser decodes multipart request bodies as UTF-8 text before Yoga can parse them, silently corrupting binary upload bytes (invalid UTF-8 sequences become replacement characters and the part's mime type is lost). The `/api/graphql` route now sets `bodyParser: false` so Yoga receives the raw stream, and `createServer` throws a descriptive error when it receives a multipart request whose body was already consumed by the bodyParser. ([@paales](https://github.com/paales))
8
+
3
9
  ## 10.1.0-canary.31
4
10
 
5
11
  ## 10.1.0-canary.30
@@ -8,6 +8,15 @@ export const createServer = async (endpoint: string) => {
8
8
 
9
9
  const handler = createBuiltMeshHTTPHandler()
10
10
  return async (req: NextApiRequest, res: NextApiResponse) => {
11
+ if (req.headers['content-type']?.startsWith('multipart/form-data') && req.body !== undefined) {
12
+ // Next's pages-router bodyParser has already consumed the request stream and decoded it as
13
+ // UTF-8 text, which corrupts binary `Upload` bytes (the multipart boundary survives, so the
14
+ // request would otherwise be forwarded with silently mangled file contents).
15
+ throw Error(
16
+ "Multipart GraphQL requests require Next.js' bodyParser to be disabled. Add `bodyParser: false` to the route config in pages/api/graphql.ts: export const config = { api: { externalResolver: true, bodyParser: false } }",
17
+ )
18
+ }
19
+
11
20
  res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*')
12
21
  const requestedHeaders = req.headers['access-control-request-headers']
13
22
  if (requestedHeaders) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/graphql-mesh",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "10.1.0-canary.31",
5
+ "version": "10.1.0-canary.32",
6
6
  "dependencies": {
7
7
  "@whatwg-node/fetch": "^0.10.13",
8
8
  "fetch-retry": "^5.0.6",
@@ -20,9 +20,9 @@
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@apollo/client": "*",
23
- "@graphcommerce/eslint-config-pwa": "^10.1.0-canary.31",
24
- "@graphcommerce/prettier-config-pwa": "^10.1.0-canary.31",
25
- "@graphcommerce/typescript-config-pwa": "^10.1.0-canary.31",
23
+ "@graphcommerce/eslint-config-pwa": "^10.1.0-canary.32",
24
+ "@graphcommerce/prettier-config-pwa": "^10.1.0-canary.32",
25
+ "@graphcommerce/typescript-config-pwa": "^10.1.0-canary.32",
26
26
  "@graphql-mesh/runtime": "*",
27
27
  "@graphql-mesh/types": "*"
28
28
  },