@cedarjs/web 6.0.2 → 6.0.3-next.227
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/dist/apollo/ApolloClientFactoryContext.d.ts +26 -0
- package/dist/apollo/ApolloClientFactoryContext.d.ts.map +1 -0
- package/dist/apollo/ApolloClientFactoryContext.js +5 -0
- package/dist/apollo/ApolloProviderWithFetchConfig.d.ts +8 -2
- package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
- package/dist/apollo/ApolloProviderWithFetchConfig.js +60 -37
- package/dist/apollo/CedarApolloProvider.d.ts.map +1 -1
- package/dist/apollo/CedarApolloProvider.js +10 -6
- package/dist/apollo/apolloLinkTypes.d.ts +4 -4
- 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 +35 -8
- package/dist/apollo/index.d.ts +4 -0
- package/dist/apollo/index.d.ts.map +1 -1
- package/dist/apollo/index.js +3 -1
- package/dist/apollo/links.d.ts +6 -5
- package/dist/apollo/links.d.ts.map +1 -1
- package/dist/apollo/links.js +14 -9
- package/dist/apollo/sseLink.d.ts +5 -8
- package/dist/apollo/sseLink.d.ts.map +1 -1
- package/dist/apollo/sseLink.js +9 -12
- package/dist/apollo/suspense.d.ts +4 -3
- package/dist/apollo/suspense.d.ts.map +1 -1
- package/dist/apollo/suspense.js +33 -7
- package/dist/apollo/useCache.d.ts +4 -6
- package/dist/apollo/useCache.d.ts.map +1 -1
- package/dist/apollo/useCache.js +1 -1
- package/dist/apollo/useCreateApolloClient.d.ts +11 -0
- package/dist/apollo/useCreateApolloClient.d.ts.map +1 -0
- package/dist/apollo/useCreateApolloClient.js +14 -0
- 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 +1562 -1734
- package/dist/components/DevFatalErrorPage.d.ts +3 -3
- package/dist/components/DevFatalErrorPage.d.ts.map +1 -1
- package/dist/components/DevFatalErrorPage.js +66 -49
- 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 +51 -18
- package/dist/components/cell/cellTypes.d.ts.map +1 -1
- package/dist/components/cell/createCell.d.ts +2 -1
- package/dist/components/cell/createCell.d.ts.map +1 -1
- package/dist/components/cell/createCell.js +65 -60
- package/dist/components/cell/createFragmentCell.d.ts +2 -1
- package/dist/components/cell/createFragmentCell.d.ts.map +1 -1
- package/dist/components/cell/createFragmentCell.js +4 -2
- package/dist/components/cell/createServerCell.d.ts +3 -2
- package/dist/components/cell/createServerCell.d.ts.map +1 -1
- package/dist/components/cell/createServerCell.js +4 -2
- package/dist/components/cell/createSuspendingCell.d.ts +2 -1
- package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
- package/dist/components/cell/createSuspendingCell.js +37 -34
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/package.json +19 -25
- package/apollo/index.js +0 -1
- package/apollo/package.json +0 -5
- package/toast/index.js +0 -1
- package/toast/package.json +0 -5
package/dist/apollo/suspense.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ApolloLink,
|
|
5
|
+
setLogVerbosity as apolloSetLogVerbosity
|
|
6
|
+
} from "@apollo/client";
|
|
7
|
+
import { SetContextLink } from "@apollo/client/link/context";
|
|
4
8
|
import {
|
|
5
9
|
ApolloClient,
|
|
6
10
|
InMemoryCache,
|
|
@@ -14,6 +18,7 @@ import {
|
|
|
14
18
|
useFetchConfig
|
|
15
19
|
} from "../components/FetchConfigProvider.js";
|
|
16
20
|
import { ServerHtmlContext } from "../components/ServerInject.js";
|
|
21
|
+
import { ApolloClientFactoryContext } from "./ApolloClientFactoryContext.js";
|
|
17
22
|
import { fragmentRegistry } from "./fragmentRegistry.js";
|
|
18
23
|
import {
|
|
19
24
|
createAuthApolloLink,
|
|
@@ -29,7 +34,7 @@ const WrappedApolloProvider = WrapApolloProvider(
|
|
|
29
34
|
}
|
|
30
35
|
})
|
|
31
36
|
);
|
|
32
|
-
const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = useNoAuth }) => {
|
|
37
|
+
const ApolloProviderWithFetchConfig = ({ config, createCache, children, logLevel, useAuth = useNoAuth }) => {
|
|
33
38
|
apolloSetLogVerbosity(logLevel);
|
|
34
39
|
const { uri, headers } = useFetchConfig();
|
|
35
40
|
const { getToken, type: authProviderType } = useAuth();
|
|
@@ -66,7 +71,24 @@ const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = u
|
|
|
66
71
|
...otherConfig
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
const createApolloClient = (options) => {
|
|
75
|
+
const extraHeaders = options?.headers;
|
|
76
|
+
const withExtraHeaders = new SetContextLink((prevContext) => ({
|
|
77
|
+
headers: { ...prevContext.headers, ...extraHeaders }
|
|
78
|
+
}));
|
|
79
|
+
return new ApolloClient({
|
|
80
|
+
...otherConfig,
|
|
81
|
+
cache: createCache(),
|
|
82
|
+
link: ApolloLink.from([
|
|
83
|
+
withExtraHeaders,
|
|
84
|
+
createFinalLink({
|
|
85
|
+
userConfiguredLink: userPassedLink,
|
|
86
|
+
defaultLinks: redwoodApolloLinks
|
|
87
|
+
})
|
|
88
|
+
])
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
return /* @__PURE__ */ React.createElement(ApolloClientFactoryContext.Provider, { value: createApolloClient }, /* @__PURE__ */ React.createElement(WrappedApolloProvider, { makeClient }, children));
|
|
70
92
|
};
|
|
71
93
|
const CedarApolloProvider = ({
|
|
72
94
|
graphQLClientConfig,
|
|
@@ -75,14 +97,18 @@ const CedarApolloProvider = ({
|
|
|
75
97
|
children
|
|
76
98
|
}) => {
|
|
77
99
|
const { cacheConfig, ...config } = graphQLClientConfig ?? {};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
const createCache = () => {
|
|
101
|
+
return new InMemoryCache({
|
|
102
|
+
fragments: fragmentRegistry,
|
|
103
|
+
...cacheConfig
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const cache = createCache().restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
|
|
82
107
|
return /* @__PURE__ */ React.createElement(FetchConfigProvider, { useAuth }, /* @__PURE__ */ React.createElement(
|
|
83
108
|
ApolloProviderWithFetchConfig,
|
|
84
109
|
{
|
|
85
110
|
config: { cache, ...config },
|
|
111
|
+
createCache,
|
|
86
112
|
useAuth,
|
|
87
113
|
logLevel
|
|
88
114
|
},
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import type { ApolloCache, Reference, StoreObject } from '@apollo/client';
|
|
2
|
-
import type { NormalizedCacheObject } from '@apollo/client/cache/inmemory/types.js';
|
|
3
|
-
import type { ApolloQueryResult } from '@apollo/client/core';
|
|
1
|
+
import type { ApolloCache, ApolloClient, NormalizedCacheObject, Reference, StoreObject } from '@apollo/client';
|
|
4
2
|
type useCacheType = {
|
|
5
|
-
cache: ApolloCache
|
|
3
|
+
cache: ApolloCache;
|
|
6
4
|
evict: (object: StoreObject | Reference) => boolean;
|
|
7
5
|
extract: (optimistic?: boolean) => NormalizedCacheObject;
|
|
8
6
|
identify: (object: StoreObject | Reference) => {
|
|
9
7
|
id: string | undefined;
|
|
10
8
|
};
|
|
11
9
|
modify: (object: StoreObject | Reference, fields: Record<string, any>) => boolean;
|
|
12
|
-
resetStore: () => Promise<
|
|
13
|
-
clearStore: () => Promise<
|
|
10
|
+
resetStore: () => Promise<ApolloClient.QueryResult<any>[] | null>;
|
|
11
|
+
clearStore: () => Promise<ApolloClient.QueryResult<any>[] | null>;
|
|
14
12
|
};
|
|
15
13
|
/**
|
|
16
14
|
* Apollo Client stores the results of your GraphQL queries in a local, normalized, in-memory cache.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCache.d.ts","sourceRoot":"","sources":["../../src/apollo/useCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useCache.d.ts","sourceRoot":"","sources":["../../src/apollo/useCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,SAAS,EACT,WAAW,EACZ,MAAM,gBAAgB,CAAA;AAGvB,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,WAAW,CAAA;IAClB,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,KAAK,OAAO,CAAA;IACnD,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,OAAO,KAAK,qBAAqB,CAAA;IACxD,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,KAAK;QAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACzE,MAAM,EAAE,CACN,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KACxB,OAAO,CAAA;IACZ,UAAU,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;IACjE,UAAU,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAA;CAClE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAAO,YAmE3B,CAAA"}
|
package/dist/apollo/useCache.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
1
|
+
import UploadHttpLink from 'apollo-upload-client/UploadHttpLink.mjs';
|
|
2
|
+
export { UploadHttpLink };
|
|
3
3
|
//# sourceMappingURL=apollo-upload-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-upload-client.d.ts","sourceRoot":"","sources":["../../src/bundled/apollo-upload-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"apollo-upload-client.d.ts","sourceRoot":"","sources":["../../src/bundled/apollo-upload-client.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,yCAAyC,CAAA;AAEpE,OAAO,EAAE,cAAc,EAAE,CAAA"}
|