@graphcommerce/graphql 10.1.0-canary.4 → 10.1.0-canary.41
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 +84 -0
- package/apolloTypeOverrides.d.ts +34 -0
- package/components/GraphQLProvider/GraphQLProvider.tsx +27 -5
- package/index.ts +2 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.1.0-canary.41
|
|
4
|
+
|
|
5
|
+
## 10.1.0-canary.40
|
|
6
|
+
|
|
7
|
+
## 10.1.0-canary.39
|
|
8
|
+
|
|
9
|
+
## 10.1.0-canary.38
|
|
10
|
+
|
|
11
|
+
## 10.1.0-canary.37
|
|
12
|
+
|
|
13
|
+
## 10.1.0-canary.36
|
|
14
|
+
|
|
15
|
+
## 10.1.0-canary.35
|
|
16
|
+
|
|
17
|
+
## 10.1.0-canary.34
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [#2646](https://github.com/graphcommerce-org/graphcommerce/pull/2646) [`35707a1`](https://github.com/graphcommerce-org/graphcommerce/commit/35707a1f68a6b8c97de5d22221a7c9229961cd7a) - Add a `terminatingLink` prop to `GraphQLProvider` to override the terminating link at the tail of the Apollo link chain (by default the `HttpLink` to the Mesh backend).
|
|
22
|
+
|
|
23
|
+
Because the terminating link runs after every context-setting link (customer auth token, store, cache-id, header links), this lets you route specific operations to a different transport while still inheriting all request headers. The motivating case is file uploads: `File`/`Blob` variables must be sent as a `multipart/form-data` request (e.g. via `apollo-upload-client`'s `UploadHttpLink`), which the default `HttpLink` cannot serialize. Previously such an upload link had to be prepended via `links`, where it terminated _before_ the auth/header links could run — dropping the customer token from multipart requests, so a logged-in customer's cart mutations were rejected. Supplying the upload-aware split as `terminatingLink` keeps it at the tail, so uploads inherit the token like any other operation. ([@paales](https://github.com/paales))
|
|
24
|
+
|
|
25
|
+
## 10.1.0-canary.33
|
|
26
|
+
|
|
27
|
+
## 10.1.0-canary.32
|
|
28
|
+
|
|
29
|
+
## 10.1.0-canary.31
|
|
30
|
+
|
|
31
|
+
## 10.1.0-canary.30
|
|
32
|
+
|
|
33
|
+
## 10.1.0-canary.29
|
|
34
|
+
|
|
35
|
+
## 10.1.0-canary.28
|
|
36
|
+
|
|
37
|
+
## 10.1.0-canary.27
|
|
38
|
+
|
|
39
|
+
## 10.1.0-canary.26
|
|
40
|
+
|
|
41
|
+
## 10.1.0-canary.25
|
|
42
|
+
|
|
43
|
+
## 10.1.0-canary.24
|
|
44
|
+
|
|
45
|
+
## 10.1.0-canary.23
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- [#2634](https://github.com/graphcommerce-org/graphcommerce/pull/2634) [`06082ad`](https://github.com/graphcommerce-org/graphcommerce/commit/06082ad47a59217fbdfb24f1a60411e4d0eecd9b) - Make GraphCommerce compatible with Apollo Client 4.2+ by augmenting Apollo's `DefaultOptions` type with the `preview` extension and the SSR clients' `errorPolicy: 'all'` default. ([@bramvanderholst](https://github.com/bramvanderholst))
|
|
50
|
+
|
|
51
|
+
## 10.1.0-canary.22
|
|
52
|
+
|
|
53
|
+
## 10.1.0-canary.21
|
|
54
|
+
|
|
55
|
+
## 10.1.0-canary.20
|
|
56
|
+
|
|
57
|
+
## 10.1.0-canary.19
|
|
58
|
+
|
|
59
|
+
## 10.1.0-canary.18
|
|
60
|
+
|
|
61
|
+
## 10.1.0-canary.17
|
|
62
|
+
|
|
63
|
+
## 10.1.0-canary.16
|
|
64
|
+
|
|
65
|
+
## 10.1.0-canary.15
|
|
66
|
+
|
|
67
|
+
## 10.1.0-canary.14
|
|
68
|
+
|
|
69
|
+
## 10.1.0-canary.13
|
|
70
|
+
|
|
71
|
+
## 10.1.0-canary.12
|
|
72
|
+
|
|
73
|
+
## 10.1.0-canary.11
|
|
74
|
+
|
|
75
|
+
## 10.1.0-canary.10
|
|
76
|
+
|
|
77
|
+
## 10.1.0-canary.9
|
|
78
|
+
|
|
79
|
+
## 10.1.0-canary.8
|
|
80
|
+
|
|
81
|
+
## 10.1.0-canary.7
|
|
82
|
+
|
|
83
|
+
## 10.1.0-canary.6
|
|
84
|
+
|
|
85
|
+
## 10.1.0-canary.5
|
|
86
|
+
|
|
3
87
|
## 10.1.0-canary.4
|
|
4
88
|
|
|
5
89
|
## 10.1.0-canary.3
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apollo Client 4.2+ type augmentations for the GraphCommerce setup.
|
|
3
|
+
*
|
|
4
|
+
* - `DefaultOptions.Input.preview` declares the `preview` extension GraphCommerce stuffs into
|
|
5
|
+
* defaultOptions so it's part of the type instead of needing an `as unknown` cast at every
|
|
6
|
+
* client-construction site.
|
|
7
|
+
* - `DeclareDefaultOptions.Query.errorPolicy: 'all'` opts the SSR clients into errorPolicy 'all'
|
|
8
|
+
* so partial GraphQL responses are returned alongside errors instead of throwing on every
|
|
9
|
+
* field-level error during SSG.
|
|
10
|
+
* - `signatureStyle: 'classic'` keeps the pre-4.2 query result typing (`T` instead of
|
|
11
|
+
* `DeepPartial<T> | undefined`) so the codebase doesn't need an app-wide migration to handle
|
|
12
|
+
* the now-correctly-modelled partial data. This is a deliberate trade-off — TS doesn't model
|
|
13
|
+
* the runtime reality of errorPolicy 'all', but it keeps consumer code ergonomic.
|
|
14
|
+
*/
|
|
15
|
+
import '@apollo/client'
|
|
16
|
+
|
|
17
|
+
declare module '@apollo/client' {
|
|
18
|
+
namespace ApolloClient {
|
|
19
|
+
namespace DefaultOptions {
|
|
20
|
+
interface Input {
|
|
21
|
+
preview: unknown
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
namespace DeclareDefaultOptions {
|
|
25
|
+
interface Query {
|
|
26
|
+
errorPolicy?: 'all'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface TypeOverrides {
|
|
32
|
+
signatureStyle: 'classic'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -20,7 +20,27 @@ export const globalApolloClient: { current: ApolloClient | null } = {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export type GraphQLProviderProps = AppProps &
|
|
23
|
-
Omit<ApolloClientConfigInput, 'storefront'> & {
|
|
23
|
+
Omit<ApolloClientConfigInput, 'storefront'> & {
|
|
24
|
+
children: React.ReactNode
|
|
25
|
+
/**
|
|
26
|
+
* Overrides the terminating link at the tail of the Apollo link chain (by default the `HttpLink`
|
|
27
|
+
* connection to the Mesh backend). Because it sits *after* every context-setting link (customer
|
|
28
|
+
* auth token, store, cache-id, header links), use it to route specific operations to a different
|
|
29
|
+
* transport while still inheriting all request headers.
|
|
30
|
+
*
|
|
31
|
+
* The motivating case is file uploads: `File`/`Blob` variables must be sent as a
|
|
32
|
+
* `multipart/form-data` request (e.g. via `apollo-upload-client`'s `UploadHttpLink`), which the
|
|
33
|
+
* default `HttpLink` cannot serialize. Providing the upload-aware split here keeps it at the tail
|
|
34
|
+
* of the chain, so uploads still pick up the customer token instead of going out unauthenticated.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const terminatingLink = ApolloLink.split(hasUploadFiles, uploadHttpLink, httpLink)
|
|
39
|
+
* <GraphQLProvider {...props} terminatingLink={terminatingLink} />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
terminatingLink?: ApolloLink
|
|
43
|
+
}
|
|
24
44
|
|
|
25
45
|
/**
|
|
26
46
|
* The GraphQLProvider allows us to configure the ApolloClient and provide it to the rest of the
|
|
@@ -29,7 +49,7 @@ export type GraphQLProviderProps = AppProps &
|
|
|
29
49
|
* Take a look at the props to see possible customization options.
|
|
30
50
|
*/
|
|
31
51
|
export function GraphQLProvider(props: GraphQLProviderProps) {
|
|
32
|
-
const { children, links, migrations, policies, pageProps, router } = props
|
|
52
|
+
const { children, links, migrations, policies, pageProps, router, terminatingLink } = props
|
|
33
53
|
const state = (pageProps as { apolloState?: unknown }).apolloState
|
|
34
54
|
|
|
35
55
|
const stateRef = useRef(state)
|
|
@@ -58,8 +78,10 @@ export function GraphQLProvider(props: GraphQLProviderProps) {
|
|
|
58
78
|
const link = ApolloLink.from([
|
|
59
79
|
...(typeof window === 'undefined' ? [errorLink, measurePerformanceLink] : []),
|
|
60
80
|
...config.current.links,
|
|
61
|
-
// The actual Http connection to the Mesh backend.
|
|
62
|
-
|
|
81
|
+
// The actual Http connection to the Mesh backend. Overridable via `terminatingLink` so
|
|
82
|
+
// e.g. multipart file uploads can be routed to a different transport while still inheriting
|
|
83
|
+
// every header set by the links above.
|
|
84
|
+
terminatingLink ?? new HttpLink({ uri: '/api/graphql', credentials: 'same-origin' }),
|
|
63
85
|
])
|
|
64
86
|
|
|
65
87
|
const cache = createCache()
|
|
@@ -76,7 +98,7 @@ export function GraphQLProvider(props: GraphQLProviderProps) {
|
|
|
76
98
|
preview: {
|
|
77
99
|
preview: router.isPreview,
|
|
78
100
|
} as PreviewConfig,
|
|
79
|
-
}
|
|
101
|
+
},
|
|
80
102
|
localState: new LocalState({}),
|
|
81
103
|
})
|
|
82
104
|
})
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/graphql",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "10.1.0-canary.
|
|
5
|
+
"version": "10.1.0-canary.41",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "index.ts",
|
|
8
8
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"rxjs": "^7.8.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@graphcommerce/eslint-config-pwa": "^10.1.0-canary.
|
|
32
|
-
"@graphcommerce/graphql-codegen-near-operation-file": "10.1.0-canary.
|
|
33
|
-
"@graphcommerce/graphql-codegen-relay-optimizer-plugin": "10.1.0-canary.
|
|
34
|
-
"@graphcommerce/next-config": "^10.1.0-canary.
|
|
35
|
-
"@graphcommerce/prettier-config-pwa": "^10.1.0-canary.
|
|
36
|
-
"@graphcommerce/typescript-config-pwa": "^10.1.0-canary.
|
|
31
|
+
"@graphcommerce/eslint-config-pwa": "^10.1.0-canary.41",
|
|
32
|
+
"@graphcommerce/graphql-codegen-near-operation-file": "10.1.0-canary.41",
|
|
33
|
+
"@graphcommerce/graphql-codegen-relay-optimizer-plugin": "10.1.0-canary.41",
|
|
34
|
+
"@graphcommerce/next-config": "^10.1.0-canary.41",
|
|
35
|
+
"@graphcommerce/prettier-config-pwa": "^10.1.0-canary.41",
|
|
36
|
+
"@graphcommerce/typescript-config-pwa": "^10.1.0-canary.41",
|
|
37
37
|
"@graphql-mesh/plugin-http-details-extensions": "*",
|
|
38
38
|
"react": "^19.2.0",
|
|
39
39
|
"react-dom": "^19.2.0"
|