@cedarjs/web 6.0.2 → 6.0.3-next.275
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 +9 -3
- package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
- package/dist/apollo/ApolloProviderWithFetchConfig.js +60 -37
- package/dist/apollo/CedarApolloProvider.d.ts +1 -0
- package/dist/apollo/CedarApolloProvider.d.ts.map +1 -1
- package/dist/apollo/CedarApolloProvider.js +11 -6
- package/dist/apollo/apolloLinkTypes.d.ts +9 -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 +5 -3
- package/dist/apollo/suspense.d.ts.map +1 -1
- package/dist/apollo/suspense.js +34 -7
- package/dist/apollo/typeOverrides.d.ts +8 -0
- package/dist/apollo/typeOverrides.d.ts.map +1 -0
- package/dist/apollo/typeOverrides.js +0 -0
- 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 +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/package.json +21 -27
- package/apollo/index.js +0 -1
- package/apollo/package.json +0 -5
- package/toast/index.js +0 -1
- package/toast/package.json +0 -5
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApolloClient as ApolloClientBase, HttpLink, InMemoryCacheConfig, setLogVerbosity } from '@apollo/client';
|
|
3
|
+
import { ApolloLink } from '@apollo/client';
|
|
3
4
|
import { InMemoryCache } from '@apollo/client-react-streaming';
|
|
5
|
+
import './typeOverrides.js';
|
|
4
6
|
import type { UseAuth } from '@cedarjs/auth';
|
|
5
7
|
import type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks } from './links.js';
|
|
6
8
|
export type ApolloClientCacheConfig = InMemoryCacheConfig;
|
|
7
9
|
export type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks, };
|
|
8
|
-
export type GraphQLClientConfigProp = Omit<
|
|
10
|
+
export type GraphQLClientConfigProp = Omit<ApolloClientBase.Options, 'cache' | 'link'> & {
|
|
9
11
|
cache?: InMemoryCache;
|
|
10
12
|
/**
|
|
11
13
|
* Configuration for Apollo Client's `InMemoryCache`.
|
|
@@ -24,7 +26,7 @@ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache'
|
|
|
24
26
|
* }}>
|
|
25
27
|
* ```
|
|
26
28
|
*/
|
|
27
|
-
httpLinkConfig?:
|
|
29
|
+
httpLinkConfig?: HttpLink.Options;
|
|
28
30
|
/**
|
|
29
31
|
* Extend or overwrite `CedarApolloProvider`'s Apollo Link.
|
|
30
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suspense.d.ts","sourceRoot":"","sources":["../../src/apollo/suspense.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"suspense.d.ts","sourceRoot":"","sources":["../../src/apollo/suspense.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EACV,YAAY,IAAI,gBAAgB,EAChC,QAAQ,EACR,mBAAmB,EACnB,eAAe,EAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,UAAU,EAEX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAEL,aAAa,EAEd,MAAM,gCAAgC,CAAA;AAGvC,OAAO,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAa5C,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AASnB,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAEzD,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,gBAAgB,CAAC,OAAO,EACxB,OAAO,GAAG,MAAM,CACjB,GAAG;IACF,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAA;IACrC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAA;IACjC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,wBAAwB,CAAA;CAC7C,CAAA;AAqHD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACxD,mBAAmB,CAAC,EAAE,uBAAuB,CAAA;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAsCA,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB;0BAhDV,uBAAuB;cACnC,OAAO;eACN,UAAU,CAAC,OAAO,eAAe,CAAC;cACnC,KAAK,CAAC,SAAS;EA6C6B,CAAA"}
|
package/dist/apollo/suspense.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
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,
|
|
7
11
|
WrapApolloProvider
|
|
8
12
|
} from "@apollo/client-react-streaming";
|
|
9
13
|
import { buildManualDataTransport } from "@apollo/client-react-streaming/manual-transport";
|
|
14
|
+
import "./typeOverrides.js";
|
|
10
15
|
import { useNoAuth } from "@cedarjs/auth";
|
|
11
16
|
import { ServerAuthContext } from "@cedarjs/auth/dist/AuthProvider/ServerAuthProvider.js";
|
|
12
17
|
import {
|
|
@@ -14,6 +19,7 @@ import {
|
|
|
14
19
|
useFetchConfig
|
|
15
20
|
} from "../components/FetchConfigProvider.js";
|
|
16
21
|
import { ServerHtmlContext } from "../components/ServerInject.js";
|
|
22
|
+
import { ApolloClientFactoryContext } from "./ApolloClientFactoryContext.js";
|
|
17
23
|
import { fragmentRegistry } from "./fragmentRegistry.js";
|
|
18
24
|
import {
|
|
19
25
|
createAuthApolloLink,
|
|
@@ -29,7 +35,7 @@ const WrappedApolloProvider = WrapApolloProvider(
|
|
|
29
35
|
}
|
|
30
36
|
})
|
|
31
37
|
);
|
|
32
|
-
const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = useNoAuth }) => {
|
|
38
|
+
const ApolloProviderWithFetchConfig = ({ config, createCache, children, logLevel, useAuth = useNoAuth }) => {
|
|
33
39
|
apolloSetLogVerbosity(logLevel);
|
|
34
40
|
const { uri, headers } = useFetchConfig();
|
|
35
41
|
const { getToken, type: authProviderType } = useAuth();
|
|
@@ -66,7 +72,24 @@ const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = u
|
|
|
66
72
|
...otherConfig
|
|
67
73
|
});
|
|
68
74
|
}
|
|
69
|
-
|
|
75
|
+
const createApolloClient = (options) => {
|
|
76
|
+
const extraHeaders = options?.headers;
|
|
77
|
+
const withExtraHeaders = new SetContextLink((prevContext) => ({
|
|
78
|
+
headers: { ...prevContext.headers, ...extraHeaders }
|
|
79
|
+
}));
|
|
80
|
+
return new ApolloClient({
|
|
81
|
+
...otherConfig,
|
|
82
|
+
cache: createCache(),
|
|
83
|
+
link: ApolloLink.from([
|
|
84
|
+
withExtraHeaders,
|
|
85
|
+
createFinalLink({
|
|
86
|
+
userConfiguredLink: userPassedLink,
|
|
87
|
+
defaultLinks: redwoodApolloLinks
|
|
88
|
+
})
|
|
89
|
+
])
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ React.createElement(ApolloClientFactoryContext.Provider, { value: createApolloClient }, /* @__PURE__ */ React.createElement(WrappedApolloProvider, { makeClient }, children));
|
|
70
93
|
};
|
|
71
94
|
const CedarApolloProvider = ({
|
|
72
95
|
graphQLClientConfig,
|
|
@@ -75,14 +98,18 @@ const CedarApolloProvider = ({
|
|
|
75
98
|
children
|
|
76
99
|
}) => {
|
|
77
100
|
const { cacheConfig, ...config } = graphQLClientConfig ?? {};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
101
|
+
const createCache = () => {
|
|
102
|
+
return new InMemoryCache({
|
|
103
|
+
fragments: fragmentRegistry,
|
|
104
|
+
...cacheConfig
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
const cache = createCache().restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
|
|
82
108
|
return /* @__PURE__ */ React.createElement(FetchConfigProvider, { useAuth }, /* @__PURE__ */ React.createElement(
|
|
83
109
|
ApolloProviderWithFetchConfig,
|
|
84
110
|
{
|
|
85
111
|
config: { cache, ...config },
|
|
112
|
+
createCache,
|
|
86
113
|
useAuth,
|
|
87
114
|
logLevel
|
|
88
115
|
},
|
|
@@ -0,0 +1 @@
|
|
|
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,16 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NormalizedCacheObject } from '@apollo/client/cache/inmemory/types.js';
|
|
3
|
-
import type { ApolloQueryResult } from '@apollo/client/core';
|
|
1
|
+
import type { ApolloClient, InMemoryCache, NormalizedCacheObject, Reference, StoreObject } from '@apollo/client';
|
|
4
2
|
type useCacheType = {
|
|
5
|
-
cache:
|
|
3
|
+
cache: InMemoryCache;
|
|
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,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,SAAS,EACT,WAAW,EACZ,MAAM,gBAAgB,CAAA;AAGvB,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,aAAa,CAAA;IACpB,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"}
|