@cedarjs/web 7.0.0-canary.3258 → 7.0.0-rc.123
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/apollo/index.js +1 -0
- package/apollo/package.json +5 -0
- package/dist/apollo/ApolloProviderWithFetchConfig.d.ts +3 -9
- package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
- package/dist/apollo/ApolloProviderWithFetchConfig.js +37 -60
- package/dist/apollo/CedarApolloProvider.d.ts +0 -1
- package/dist/apollo/CedarApolloProvider.d.ts.map +1 -1
- package/dist/apollo/CedarApolloProvider.js +6 -13
- package/dist/apollo/apolloLinkTypes.d.ts +4 -9
- package/dist/apollo/apolloLinkTypes.d.ts.map +1 -1
- package/dist/apollo/fragmentRegistry.d.ts +3 -3
- package/dist/apollo/fragmentRegistry.d.ts.map +1 -1
- package/dist/apollo/fragmentRegistry.js +8 -35
- package/dist/apollo/index.d.ts +0 -4
- package/dist/apollo/index.d.ts.map +1 -1
- package/dist/apollo/index.js +1 -3
- package/dist/apollo/links.d.ts +5 -6
- package/dist/apollo/links.d.ts.map +1 -1
- package/dist/apollo/links.js +9 -14
- package/dist/apollo/sseLink.d.ts +8 -5
- package/dist/apollo/sseLink.d.ts.map +1 -1
- package/dist/apollo/sseLink.js +12 -9
- package/dist/apollo/suspense.d.ts +3 -5
- package/dist/apollo/suspense.d.ts.map +1 -1
- package/dist/apollo/suspense.js +7 -35
- package/dist/apollo/useCache.d.ts +6 -4
- package/dist/apollo/useCache.d.ts.map +1 -1
- package/dist/apollo/useCache.js +1 -1
- package/dist/bundled/apollo-upload-client.d.ts +2 -2
- package/dist/bundled/apollo-upload-client.d.ts.map +1 -1
- package/dist/bundled/apollo-upload-client.js +1685 -1513
- package/dist/components/DevFatalErrorPage.d.ts +3 -3
- package/dist/components/DevFatalErrorPage.d.ts.map +1 -1
- package/dist/components/DevFatalErrorPage.js +49 -66
- package/dist/components/FatalErrorBoundary.d.ts +1 -1
- package/dist/components/cell/CellErrorBoundary.d.ts +3 -3
- package/dist/components/cell/CellErrorBoundary.d.ts.map +1 -1
- package/dist/components/cell/cellTypes.d.ts +18 -51
- package/dist/components/cell/cellTypes.d.ts.map +1 -1
- package/dist/components/cell/createCell.d.ts +1 -2
- package/dist/components/cell/createCell.d.ts.map +1 -1
- package/dist/components/cell/createCell.js +60 -65
- package/dist/components/cell/createFragmentCell.d.ts +1 -2
- package/dist/components/cell/createFragmentCell.d.ts.map +1 -1
- package/dist/components/cell/createFragmentCell.js +2 -4
- package/dist/components/cell/createServerCell.d.ts +2 -3
- package/dist/components/cell/createServerCell.d.ts.map +1 -1
- package/dist/components/cell/createServerCell.js +2 -4
- package/dist/components/cell/createSuspendingCell.d.ts +1 -2
- package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
- package/dist/components/cell/createSuspendingCell.js +34 -37
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/package.json +26 -20
- package/toast/index.js +1 -0
- package/toast/package.json +5 -0
- package/dist/apollo/ApolloClientFactoryContext.d.ts +0 -26
- package/dist/apollo/ApolloClientFactoryContext.d.ts.map +0 -1
- package/dist/apollo/ApolloClientFactoryContext.js +0 -5
- package/dist/apollo/parsedScalars.d.ts +0 -36
- package/dist/apollo/parsedScalars.d.ts.map +0 -1
- package/dist/apollo/parsedScalars.js +0 -75
- package/dist/apollo/typeOverrides.d.ts +0 -8
- package/dist/apollo/typeOverrides.d.ts.map +0 -1
- package/dist/apollo/typeOverrides.js +0 -0
- package/dist/apollo/useCreateApolloClient.d.ts +0 -11
- package/dist/apollo/useCreateApolloClient.d.ts.map +0 -1
- package/dist/apollo/useCreateApolloClient.js +0 -14
|
@@ -26,11 +26,9 @@ function createServerCell(createCellProps) {
|
|
|
26
26
|
try {
|
|
27
27
|
const data = await dataFn(variables);
|
|
28
28
|
if (isEmpty(data, { isDataEmpty }) && Empty) {
|
|
29
|
-
|
|
30
|
-
return /* @__PURE__ */ React.createElement(Empty, { ...emptyProps });
|
|
29
|
+
return /* @__PURE__ */ React.createElement(Empty, { ...props, ...data });
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
return /* @__PURE__ */ React.createElement(Success, { ...successProps });
|
|
31
|
+
return /* @__PURE__ */ React.createElement(Success, { ...data, ...props });
|
|
34
32
|
} catch (error) {
|
|
35
33
|
return /* @__PURE__ */ React.createElement(FailureComponent, { error });
|
|
36
34
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { OperationVariables } from '@apollo/client';
|
|
3
2
|
import type { CreateCellProps } from './cellTypes.js';
|
|
4
3
|
type AnyObj = Record<string, unknown>;
|
|
5
4
|
/**
|
|
@@ -7,6 +6,6 @@ type AnyObj = Record<string, unknown>;
|
|
|
7
6
|
* using the hooks useBackgroundQuery and useReadQuery
|
|
8
7
|
*
|
|
9
8
|
*/
|
|
10
|
-
export declare function createSuspendingCell<CellProps extends AnyObj, CellVariables extends
|
|
9
|
+
export declare function createSuspendingCell<CellProps extends AnyObj, CellVariables extends AnyObj>(createCellProps: CreateCellProps<AnyObj, CellVariables>): React.FC<CellProps>;
|
|
11
10
|
export {};
|
|
12
11
|
//# sourceMappingURL=createSuspendingCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspendingCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createSuspendingCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"createSuspendingCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createSuspendingCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAWvC,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,gBAAgB,CAAA;AAGvB,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACrC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,MAAM,EAE5B,eAAe,EAAE,eAAe,CAAC,MAAM,EAAE,aAAa,CAAC,GACtD,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAiJrB"}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import React, { Suspense } from "react";
|
|
2
|
-
import { CombinedGraphQLErrors } from "@apollo/client";
|
|
3
2
|
import {
|
|
4
3
|
useApolloClient,
|
|
5
4
|
useBackgroundQuery,
|
|
6
5
|
useReadQuery
|
|
7
|
-
} from "@apollo/client/react";
|
|
6
|
+
} from "@apollo/client/react/hooks/hooks.cjs";
|
|
8
7
|
import { CellErrorBoundary } from "./CellErrorBoundary.js";
|
|
9
8
|
import { isDataEmpty } from "./isCellEmpty.js";
|
|
10
9
|
function createSuspendingCell(createCellProps) {
|
|
11
10
|
const {
|
|
12
11
|
QUERY,
|
|
13
|
-
// Unlike in createCell this is destructured from a variable rather than
|
|
14
|
-
// from an annotated parameter, so the default's return type has to be
|
|
15
|
-
// spelled out. Without it the inferred object literal type widens the
|
|
16
|
-
// union and options like `skip` are no longer visible on it
|
|
17
12
|
beforeQuery = (props) => ({
|
|
18
13
|
// By default, we assume that the props are the gql-variables.
|
|
19
14
|
variables: props,
|
|
@@ -49,36 +44,31 @@ function createSuspendingCell(createCellProps) {
|
|
|
49
44
|
networkStatus
|
|
50
45
|
};
|
|
51
46
|
if (isEmpty(data, { isDataEmpty }) && Empty) {
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
return /* @__PURE__ */ React.createElement(
|
|
48
|
+
Empty,
|
|
49
|
+
{
|
|
50
|
+
...userProps,
|
|
51
|
+
...afterQueryData,
|
|
52
|
+
queryResult: queryResultWithNetworkStatus
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ React.createElement(
|
|
57
|
+
Success,
|
|
58
|
+
{
|
|
54
59
|
...afterQueryData,
|
|
60
|
+
...userProps,
|
|
55
61
|
queryResult: queryResultWithNetworkStatus
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
const successProps = {
|
|
60
|
-
...afterQueryData,
|
|
61
|
-
...userProps,
|
|
62
|
-
queryResult: queryResultWithNetworkStatus
|
|
63
|
-
};
|
|
64
|
-
return /* @__PURE__ */ React.createElement(Success, { ...successProps });
|
|
62
|
+
}
|
|
63
|
+
);
|
|
65
64
|
}
|
|
66
65
|
SuspendingSuccess.displayName = displayName;
|
|
67
66
|
return (props) => {
|
|
68
67
|
const { children: _, ...variables } = props;
|
|
69
68
|
const options = beforeQuery(variables);
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const query = typeof cellQuery === "function" ? cellQuery(queryOptions ?? {}) : cellQuery;
|
|
73
|
-
const backgroundQueryOptions = options;
|
|
74
|
-
const [queryRef, other] = useBackgroundQuery(
|
|
75
|
-
query,
|
|
76
|
-
backgroundQueryOptions
|
|
77
|
-
);
|
|
69
|
+
const query = typeof cellQuery === "function" ? cellQuery(options) : cellQuery;
|
|
70
|
+
const [queryRef, other] = useBackgroundQuery(query, options);
|
|
78
71
|
const client = useApolloClient();
|
|
79
|
-
if (skipped || !queryRef) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
72
|
const suspenseQueryResult = {
|
|
83
73
|
client,
|
|
84
74
|
...other,
|
|
@@ -87,7 +77,7 @@ function createSuspendingCell(createCellProps) {
|
|
|
87
77
|
const FailureComponent = ({ error, resetErrorBoundary }) => {
|
|
88
78
|
if (!Failure) {
|
|
89
79
|
if (error) {
|
|
90
|
-
throw error
|
|
80
|
+
throw error;
|
|
91
81
|
}
|
|
92
82
|
throw new Error("Unreachable code: FailureComponent without a Failure");
|
|
93
83
|
}
|
|
@@ -98,19 +88,26 @@ function createSuspendingCell(createCellProps) {
|
|
|
98
88
|
return suspenseQueryResult.refetch?.(variables2);
|
|
99
89
|
}
|
|
100
90
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
return /* @__PURE__ */ React.createElement(
|
|
92
|
+
Failure,
|
|
93
|
+
{
|
|
94
|
+
error,
|
|
95
|
+
errorCode: error?.graphQLErrors?.[0]?.extensions?.["code"],
|
|
96
|
+
queryResult: queryResultWithErrorReset
|
|
97
|
+
}
|
|
98
|
+
);
|
|
107
99
|
};
|
|
108
100
|
const wrapInSuspenseIfLoadingPresent = (suspendingSuccessElement, LoadingComponent) => {
|
|
109
101
|
if (!LoadingComponent) {
|
|
110
102
|
return suspendingSuccessElement;
|
|
111
103
|
}
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
return /* @__PURE__ */ React.createElement(
|
|
105
|
+
Suspense,
|
|
106
|
+
{
|
|
107
|
+
fallback: /* @__PURE__ */ React.createElement(LoadingComponent, { ...props, queryResult: suspenseQueryResult })
|
|
108
|
+
},
|
|
109
|
+
suspendingSuccessElement
|
|
110
|
+
);
|
|
114
111
|
};
|
|
115
112
|
return /* @__PURE__ */ React.createElement(CellErrorBoundary, { renderFallback: FailureComponent }, wrapInSuspenseIfLoadingPresent(
|
|
116
113
|
/* @__PURE__ */ React.createElement(
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import './global.web-auto-imports.js';
|
|
2
|
-
import './apollo/typeOverrides.js';
|
|
3
2
|
import './config.js';
|
|
4
3
|
export { FatalErrorBoundary } from './components/FatalErrorBoundary.js';
|
|
5
4
|
export { FetchConfigProvider, useFetchConfig, } from './components/FetchConfigProvider.js';
|
|
6
|
-
export { useQuery, useMutation, useSubscription } from '@apollo/client/react';
|
|
5
|
+
export { useQuery, useMutation, useSubscription, } from '@apollo/client/react/hooks/hooks.cjs';
|
|
7
6
|
export { useFragment } from './apollo/fragmentRegistry.js';
|
|
8
7
|
export type { FragmentHookOptions, FragmentHookResult, } from './apollo/fragmentRegistry.js';
|
|
9
8
|
export * from './components/cell/CellCacheContext.js';
|
|
10
9
|
export { createCell } from './components/cell/createCell.js';
|
|
11
10
|
export { createFragmentCell } from './components/cell/createFragmentCell.js';
|
|
12
|
-
export type { CellProps, CellFailureProps, CellLoadingProps, CellSuccessProps, CellSuccessData,
|
|
11
|
+
export type { CellProps, CellFailureProps, CellLoadingProps, CellSuccessProps, CellSuccessData, } from './components/cell/cellTypes.js';
|
|
13
12
|
export * from './graphql.js';
|
|
14
13
|
export * from './components/CedarProvider.js';
|
|
15
14
|
export * from './components/MetaTags.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAA;AACrC,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAEvE,OAAO,EACL,mBAAmB,EACnB,cAAc,GACf,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,QAAQ,EACR,WAAW,EACX,eAAe,GAChB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,YAAY,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,8BAA8B,CAAA;AAErC,cAAc,uCAAuC,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAE5E,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,gCAAgC,CAAA;AAEvC,cAAc,cAAc,CAAA;AAE5B,cAAc,+BAA+B,CAAA;AAE7C,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,MAAM,EAAE,CAAA;AAEjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AAErC,cAAc,8BAA8B,CAAA;AAE5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import "./global.web-auto-imports.js";
|
|
2
|
-
import "./apollo/typeOverrides.js";
|
|
3
2
|
import "./config.js";
|
|
4
3
|
import { FatalErrorBoundary } from "./components/FatalErrorBoundary.js";
|
|
5
4
|
import {
|
|
6
5
|
FetchConfigProvider,
|
|
7
6
|
useFetchConfig
|
|
8
7
|
} from "./components/FetchConfigProvider.js";
|
|
9
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
useQuery,
|
|
10
|
+
useMutation,
|
|
11
|
+
useSubscription
|
|
12
|
+
} from "@apollo/client/react/hooks/hooks.cjs";
|
|
10
13
|
import { useFragment } from "./apollo/fragmentRegistry.js";
|
|
11
14
|
export * from "./components/cell/CellCacheContext.js";
|
|
12
15
|
import { createCell } from "./components/cell/createCell.js";
|
|
@@ -8,7 +8,7 @@ export type MiddlewareInvokeOptions = {
|
|
|
8
8
|
route?: RWRouteManifestItem;
|
|
9
9
|
cssPaths?: string[];
|
|
10
10
|
params?: Record<string, unknown>;
|
|
11
|
-
|
|
11
|
+
viteDevServer?: ViteDevServer;
|
|
12
12
|
};
|
|
13
13
|
export type Middleware = (req: MiddlewareRequest, res: MiddlewareResponse, options?: MiddlewareInvokeOptions) => Promise<MiddlewareResponse> | MiddlewareResponse | void;
|
|
14
14
|
export interface MiddlewareClass {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAIzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AAEvC,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAIzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AAEvC,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,CACvB,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,kBAAkB,EACvB,OAAO,CAAC,EAAE,uBAAuB,KAC9B,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,GAAG,IAAI,CAAA;AAE5D,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAA;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/web",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.123",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -63,7 +63,9 @@
|
|
|
63
63
|
"tsc": "./dist/bins/tsc.js"
|
|
64
64
|
},
|
|
65
65
|
"files": [
|
|
66
|
-
"dist"
|
|
66
|
+
"dist",
|
|
67
|
+
"apollo",
|
|
68
|
+
"toast"
|
|
67
69
|
],
|
|
68
70
|
"scripts": {
|
|
69
71
|
"build": "node ./build.ts",
|
|
@@ -78,45 +80,49 @@
|
|
|
78
80
|
"test:watch": "vitest watch"
|
|
79
81
|
},
|
|
80
82
|
"dependencies": {
|
|
81
|
-
"@apollo/client": "
|
|
82
|
-
"@cedarjs/server-store": "7.0.0-
|
|
83
|
+
"@apollo/client": "3.14.1",
|
|
84
|
+
"@cedarjs/server-store": "7.0.0-rc.123",
|
|
83
85
|
"@dr.pogodin/react-helmet": "2.0.4",
|
|
84
|
-
"@whatwg-node/fetch": "0.
|
|
85
|
-
"apollo-upload-client": "
|
|
86
|
+
"@whatwg-node/fetch": "0.10.13",
|
|
87
|
+
"apollo-upload-client": "18.0.1",
|
|
86
88
|
"cookie": "1.1.1",
|
|
87
89
|
"graphql": "16.14.2",
|
|
88
90
|
"graphql-sse": "2.6.1",
|
|
89
|
-
"graphql-tag": "2.12.
|
|
91
|
+
"graphql-tag": "2.12.6",
|
|
90
92
|
"react-hot-toast": "2.6.1",
|
|
91
|
-
"rxjs": "7.8.2",
|
|
92
93
|
"stacktracey": "2.2.0",
|
|
93
94
|
"ts-toolbelt": "9.6.0"
|
|
94
95
|
},
|
|
95
96
|
"devDependencies": {
|
|
96
|
-
"@apollo/client-react-streaming": "0.
|
|
97
|
+
"@apollo/client-react-streaming": "0.12.3",
|
|
97
98
|
"@arethetypeswrong/cli": "0.18.5",
|
|
98
|
-
"@
|
|
99
|
-
"@
|
|
100
|
-
"@
|
|
99
|
+
"@babel/cli": "7.29.7",
|
|
100
|
+
"@babel/core": "^7.26.10",
|
|
101
|
+
"@babel/plugin-transform-runtime": "7.29.7",
|
|
102
|
+
"@babel/runtime": "7.29.7",
|
|
103
|
+
"@cedarjs/auth": "7.0.0-rc.123",
|
|
104
|
+
"@cedarjs/framework-tools": "7.0.0-rc.123",
|
|
105
|
+
"@cedarjs/internal": "7.0.0-rc.123",
|
|
106
|
+
"@rollup/plugin-babel": "6.1.0",
|
|
101
107
|
"@testing-library/dom": "10.4.2",
|
|
102
108
|
"@testing-library/jest-dom": "6.9.1",
|
|
103
109
|
"@testing-library/react": "16.3.3",
|
|
104
|
-
"@types/apollo-upload-client": "^
|
|
105
|
-
"@types/react": "^
|
|
106
|
-
"@types/react-dom": "^
|
|
110
|
+
"@types/apollo-upload-client": "^18",
|
|
111
|
+
"@types/react": "^18.2.55",
|
|
112
|
+
"@types/react-dom": "^18.2.19",
|
|
107
113
|
"concurrently": "9.2.4",
|
|
108
114
|
"nodemon": "3.1.14",
|
|
109
115
|
"publint": "0.3.24",
|
|
110
|
-
"react": "
|
|
111
|
-
"react-dom": "
|
|
116
|
+
"react": "18.3.1",
|
|
117
|
+
"react-dom": "18.3.1",
|
|
112
118
|
"tstyche": "5.0.2",
|
|
113
119
|
"typescript": "5.9.3",
|
|
114
120
|
"vitest": "4.1.11"
|
|
115
121
|
},
|
|
116
122
|
"peerDependencies": {
|
|
117
|
-
"@cedarjs/auth": "7.0.0-
|
|
118
|
-
"react": "
|
|
119
|
-
"react-dom": "
|
|
123
|
+
"@cedarjs/auth": "7.0.0-rc.123",
|
|
124
|
+
"react": "18.3.1",
|
|
125
|
+
"react-dom": "18.3.1"
|
|
120
126
|
},
|
|
121
127
|
"engines": {
|
|
122
128
|
"node": ">=24"
|
package/toast/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/toast')
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ApolloClient } from '@apollo/client';
|
|
3
|
-
/**
|
|
4
|
-
* Options accepted by the client factory that `useCreateApolloClient`
|
|
5
|
-
* returns.
|
|
6
|
-
*/
|
|
7
|
-
export interface CreateApolloClientOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Extra headers merged into every operation's headers, alongside the ones
|
|
10
|
-
* `CedarApolloProvider`'s own link chain already sets (auth headers, the
|
|
11
|
-
* headers from `useFetchConfig`, and so on).
|
|
12
|
-
*/
|
|
13
|
-
headers?: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Builds a new `ApolloClient` that shares `CedarApolloProvider`'s link
|
|
17
|
-
* chain, `defaultOptions` and client config, but gets its own fresh cache
|
|
18
|
-
* and, when given, extra headers on every operation.
|
|
19
|
-
*/
|
|
20
|
-
export type CreateApolloClient = (options?: CreateApolloClientOptions) => ApolloClient;
|
|
21
|
-
/**
|
|
22
|
-
* Set by `ApolloProviderWithFetchConfig` so that `useCreateApolloClient` can
|
|
23
|
-
* build additional Apollo clients from the same configuration.
|
|
24
|
-
*/
|
|
25
|
-
export declare const ApolloClientFactoryContext: React.Context<CreateApolloClient | undefined>;
|
|
26
|
-
//# sourceMappingURL=ApolloClientFactoryContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloClientFactoryContext.d.ts","sourceRoot":"","sources":["../../src/apollo/ApolloClientFactoryContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,CAAC,EAAE,yBAAyB,KAChC,YAAY,CAAA;AAEjB;;;GAGG;AACH,eAAO,MAAM,0BAA0B,+CAE3B,CAAA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { InMemoryCacheConfig } from '@apollo/client';
|
|
2
|
-
/**
|
|
3
|
-
* The cache config that `vite-plugin-cedar-parsed-scalars` builds from the
|
|
4
|
-
* project's GraphQL schema and the `graphql.parsedScalars` setting in
|
|
5
|
-
* `cedar.toml`, and puts on `globalThis.__CEDAR__PARSED_SCALARS`.
|
|
6
|
-
*/
|
|
7
|
-
export interface ParsedScalarsCacheConfig {
|
|
8
|
-
/**
|
|
9
|
-
* The scalars to parse, and the type each is parsed into
|
|
10
|
-
*/
|
|
11
|
-
scalars: Record<string, string>;
|
|
12
|
-
/**
|
|
13
|
-
* The fields that hold a parsed scalar
|
|
14
|
-
*/
|
|
15
|
-
typePolicies: Record<string, {
|
|
16
|
-
fields: Record<string, {
|
|
17
|
-
scalar: string;
|
|
18
|
-
}>;
|
|
19
|
-
}>;
|
|
20
|
-
/**
|
|
21
|
-
* The input objects that hold a parsed scalar, directly or through another
|
|
22
|
-
* input object
|
|
23
|
-
*/
|
|
24
|
-
inputObjects: Record<string, {
|
|
25
|
-
fields: Record<string, string>;
|
|
26
|
-
}>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Adds the scalars in `graphql.parsedScalars` to the cache config, so that
|
|
30
|
-
* Apollo Client's cache parses them when it reads a response and serializes
|
|
31
|
-
* them in a query's variables. Anything the app configured for the same
|
|
32
|
-
* scalar, field or input object takes precedence. Returns the config as it is
|
|
33
|
-
* when no scalar is parsed.
|
|
34
|
-
*/
|
|
35
|
-
export declare function withParsedScalars(cacheConfig?: InMemoryCacheConfig): InMemoryCacheConfig | undefined;
|
|
36
|
-
//# sourceMappingURL=parsedScalars.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parsedScalars.d.ts","sourceRoot":"","sources":["../../src/apollo/parsedScalars.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,gBAAgB,CAAA;AAEvE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAA;IAC5E;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAA;CACjE;AAmFD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,CAAC,EAAE,mBAAmB,GAChC,mBAAmB,GAAG,SAAS,CAmDjC"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Scalar } from "@apollo/client";
|
|
2
|
-
const SCALAR_TYPES = {
|
|
3
|
-
Date: new Scalar({
|
|
4
|
-
parse: (serialized) => new Date(serialized),
|
|
5
|
-
serialize: (parsed) => parsed.toISOString(),
|
|
6
|
-
is: (value) => value instanceof Date
|
|
7
|
-
})
|
|
8
|
-
};
|
|
9
|
-
function mergeFieldPolicies(typeName, generated, configured = {}) {
|
|
10
|
-
const fields = { ...configured };
|
|
11
|
-
for (const [name, policy] of Object.entries(generated)) {
|
|
12
|
-
const configuredPolicy = configured[name];
|
|
13
|
-
const hasReadOrMerge = typeof configuredPolicy === "function" || configuredPolicy?.read !== void 0 || configuredPolicy?.merge !== void 0;
|
|
14
|
-
if (hasReadOrMerge) {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`${typeName}.${name} holds a parsed ${policy.scalar} scalar and has a \`read\` or \`merge\` field policy. Apollo Client drops a field policy's \`read\` and \`merge\` the moment \`scalar\` is also set on it, so they can\u2019t both apply. Move the \`read\`/\`merge\` logic to a different field, for example one backed by a \`@requires\`-style resolver, or stop parsing this scalar.`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
fields[name] = {
|
|
20
|
-
...policy,
|
|
21
|
-
...configuredPolicy
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return fields;
|
|
25
|
-
}
|
|
26
|
-
function mergeInputObjects(generated, configured = {}) {
|
|
27
|
-
const inputObjects = { ...configured };
|
|
28
|
-
for (const [name, { fields }] of Object.entries(generated)) {
|
|
29
|
-
inputObjects[name] = {
|
|
30
|
-
...configured[name],
|
|
31
|
-
fields: { ...fields, ...configured[name]?.fields }
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return inputObjects;
|
|
35
|
-
}
|
|
36
|
-
function withParsedScalars(cacheConfig) {
|
|
37
|
-
const parsed = globalThis.__CEDAR__PARSED_SCALARS;
|
|
38
|
-
if (!parsed) {
|
|
39
|
-
return cacheConfig;
|
|
40
|
-
}
|
|
41
|
-
const scalars = Object.fromEntries(
|
|
42
|
-
Object.entries(parsed.scalars).map(([name, type]) => {
|
|
43
|
-
const scalarType = SCALAR_TYPES[type];
|
|
44
|
-
if (!scalarType) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Can't parse the ${name} scalar into ${JSON.stringify(type)}. Supported: ` + Object.keys(SCALAR_TYPES).map((supported) => JSON.stringify(supported)).join(", ")
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return [name, scalarType];
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
const typePolicies = { ...cacheConfig?.typePolicies };
|
|
53
|
-
for (const [typeName, { fields }] of Object.entries(parsed.typePolicies)) {
|
|
54
|
-
typePolicies[typeName] = {
|
|
55
|
-
...typePolicies[typeName],
|
|
56
|
-
fields: mergeFieldPolicies(
|
|
57
|
-
typeName,
|
|
58
|
-
fields,
|
|
59
|
-
typePolicies[typeName]?.fields
|
|
60
|
-
)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
...cacheConfig,
|
|
65
|
-
scalars: { ...scalars, ...cacheConfig?.scalars },
|
|
66
|
-
typePolicies,
|
|
67
|
-
inputObjects: mergeInputObjects(
|
|
68
|
-
parsed.inputObjects,
|
|
69
|
-
cacheConfig?.inputObjects
|
|
70
|
-
)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
withParsedScalars
|
|
75
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeOverrides.d.ts","sourceRoot":"","sources":["../../src/apollo/typeOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAanD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAU,aAAa;QACrB,KAAK,EAAE,aAAa,CAAA;KACrB;CACF;AAED,OAAO,EAAE,CAAA"}
|
|
File without changes
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CreateApolloClient } from './ApolloClientFactoryContext.js';
|
|
2
|
-
/**
|
|
3
|
-
* Returns a factory that builds a new `ApolloClient` sharing
|
|
4
|
-
* `CedarApolloProvider`'s link chain, auth headers and `defaultOptions`, but
|
|
5
|
-
* with its own fresh `InMemoryCache` and, when given, extra headers merged
|
|
6
|
-
* into every operation.
|
|
7
|
-
*
|
|
8
|
-
* Must be called from a component rendered under `CedarApolloProvider`.
|
|
9
|
-
*/
|
|
10
|
-
export declare function useCreateApolloClient(): CreateApolloClient;
|
|
11
|
-
//# sourceMappingURL=useCreateApolloClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateApolloClient.d.ts","sourceRoot":"","sources":["../../src/apollo/useCreateApolloClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAGzE;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAU1D"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ApolloClientFactoryContext } from "./ApolloClientFactoryContext.js";
|
|
3
|
-
function useCreateApolloClient() {
|
|
4
|
-
const createClient = React.useContext(ApolloClientFactoryContext);
|
|
5
|
-
if (!createClient) {
|
|
6
|
-
throw new Error(
|
|
7
|
-
"useCreateApolloClient must be used within a CedarApolloProvider"
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
return createClient;
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
useCreateApolloClient
|
|
14
|
-
};
|