@cedarjs/web 7.0.0 → 8.0.0-canary.3265
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 +13 -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/parsedScalars.d.ts +36 -0
- package/dist/apollo/parsedScalars.d.ts.map +1 -0
- package/dist/apollo/parsedScalars.js +75 -0
- 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 +35 -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/dist/server/middleware.d.ts +1 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/package.json +20 -26
- package/apollo/index.js +0 -1
- package/apollo/package.json +0 -5
- package/toast/index.js +0 -1
- package/toast/package.json +0 -5
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
};
|
package/dist/apollo/sseLink.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { ApolloLink } from '@apollo/client/link/core/core.cjs';
|
|
4
|
-
import { Observable } from '@apollo/client/utilities/utilities.cjs';
|
|
1
|
+
import type { HttpLink } from '@apollo/client';
|
|
2
|
+
import { ApolloLink } from '@apollo/client';
|
|
5
3
|
import type { DefinitionNode } from 'graphql';
|
|
6
4
|
import type { ClientOptions } from 'graphql-sse';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
7
6
|
interface SSELinkOptions extends Partial<ClientOptions> {
|
|
8
7
|
url: string;
|
|
9
8
|
auth: {
|
|
10
9
|
authProviderType: string;
|
|
11
10
|
tokenFn: () => Promise<null | string>;
|
|
12
11
|
};
|
|
13
|
-
httpLinkConfig?:
|
|
12
|
+
httpLinkConfig?: HttpLink.Options;
|
|
14
13
|
headers?: Record<string, string>;
|
|
15
14
|
}
|
|
16
15
|
declare const isSubscription: (definition: DefinitionNode) => boolean;
|
|
@@ -21,9 +20,7 @@ declare const isLiveQuery: (definition: DefinitionNode) => boolean;
|
|
|
21
20
|
declare class SSELink extends ApolloLink {
|
|
22
21
|
private client;
|
|
23
22
|
constructor(options: SSELinkOptions);
|
|
24
|
-
request(operation: Operation
|
|
25
|
-
query?: any;
|
|
26
|
-
}): Observable<FetchResult>;
|
|
23
|
+
request(operation: ApolloLink.Operation): Observable<ApolloLink.Result>;
|
|
27
24
|
}
|
|
28
25
|
export { SSELink, isSubscription, isLiveQuery };
|
|
29
26
|
//# sourceMappingURL=sseLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sseLink.d.ts","sourceRoot":"","sources":["../../src/apollo/sseLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sseLink.d.ts","sourceRoot":"","sources":["../../src/apollo/sseLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,aAAa,CAAA;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACjC,UAAU,cAAe,SAAQ,OAAO,CAAC,aAAa,CAAC;IACrD,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAAA;KAAE,CAAA;IACzE,cAAc,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAA;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAsDD,QAAA,MAAM,cAAc,GAAI,YAAY,cAAc,YAKjD,CAAA;AAID,QAAA,MAAM,WAAW,GAAI,YAAY,cAAc,YAS9C,CAAA;AAED;;GAEG;AACH,cAAM,OAAQ,SAAQ,UAAU;IAC9B,OAAO,CAAC,MAAM,CAAQ;gBAEV,OAAO,EAAE,cAAc;IA2B5B,OAAO,CACZ,SAAS,EAAE,UAAU,CAAC,SAAS,GAC9B,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC;CA6BjC;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,CAAA"}
|
package/dist/apollo/sseLink.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ApolloLink } from "@apollo/client
|
|
2
|
-
import { Observable } from "@apollo/client/utilities/utilities.cjs";
|
|
1
|
+
import { ApolloLink } from "@apollo/client";
|
|
3
2
|
import { Kind, OperationTypeNode, print } from "graphql";
|
|
4
3
|
import { createClient } from "graphql-sse";
|
|
4
|
+
import { Observable } from "rxjs";
|
|
5
5
|
const mapCredentialsHeader = (httpLinkCredentials) => {
|
|
6
6
|
if (!httpLinkCredentials) {
|
|
7
7
|
return void 0;
|
|
@@ -69,16 +69,13 @@ class SSELink extends ApolloLink {
|
|
|
69
69
|
}
|
|
70
70
|
request(operation) {
|
|
71
71
|
return new Observable((sink) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
query: print(operation.query)
|
|
80
|
-
};
|
|
81
|
-
}
|
|
72
|
+
const { operationName, variables, extensions } = operation;
|
|
73
|
+
const request = hasTrustedDocument(operation) ? { operationName, variables, extensions } : {
|
|
74
|
+
operationName,
|
|
75
|
+
variables,
|
|
76
|
+
extensions,
|
|
77
|
+
query: print(operation.query)
|
|
78
|
+
};
|
|
82
79
|
return this.client.subscribe(request, {
|
|
83
80
|
next: sink.next.bind(sink),
|
|
84
81
|
complete: sink.complete.bind(sink),
|
|
@@ -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;AAUnB,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,
|
|
@@ -22,6 +28,7 @@ import {
|
|
|
22
28
|
createTokenLink,
|
|
23
29
|
createUpdateDataLink
|
|
24
30
|
} from "./links.js";
|
|
31
|
+
import { withParsedScalars } from "./parsedScalars.js";
|
|
25
32
|
const WrappedApolloProvider = WrapApolloProvider(
|
|
26
33
|
buildManualDataTransport({
|
|
27
34
|
useInsertHtml() {
|
|
@@ -29,7 +36,7 @@ const WrappedApolloProvider = WrapApolloProvider(
|
|
|
29
36
|
}
|
|
30
37
|
})
|
|
31
38
|
);
|
|
32
|
-
const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = useNoAuth }) => {
|
|
39
|
+
const ApolloProviderWithFetchConfig = ({ config, createCache, children, logLevel, useAuth = useNoAuth }) => {
|
|
33
40
|
apolloSetLogVerbosity(logLevel);
|
|
34
41
|
const { uri, headers } = useFetchConfig();
|
|
35
42
|
const { getToken, type: authProviderType } = useAuth();
|
|
@@ -66,7 +73,24 @@ const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = u
|
|
|
66
73
|
...otherConfig
|
|
67
74
|
});
|
|
68
75
|
}
|
|
69
|
-
|
|
76
|
+
const createApolloClient = (options) => {
|
|
77
|
+
const extraHeaders = options?.headers;
|
|
78
|
+
const withExtraHeaders = new SetContextLink((prevContext) => ({
|
|
79
|
+
headers: { ...prevContext.headers, ...extraHeaders }
|
|
80
|
+
}));
|
|
81
|
+
return new ApolloClient({
|
|
82
|
+
...otherConfig,
|
|
83
|
+
cache: createCache(),
|
|
84
|
+
link: ApolloLink.from([
|
|
85
|
+
withExtraHeaders,
|
|
86
|
+
createFinalLink({
|
|
87
|
+
userConfiguredLink: userPassedLink,
|
|
88
|
+
defaultLinks: redwoodApolloLinks
|
|
89
|
+
})
|
|
90
|
+
])
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ React.createElement(ApolloClientFactoryContext.Provider, { value: createApolloClient }, /* @__PURE__ */ React.createElement(WrappedApolloProvider, { makeClient }, children));
|
|
70
94
|
};
|
|
71
95
|
const CedarApolloProvider = ({
|
|
72
96
|
graphQLClientConfig,
|
|
@@ -75,14 +99,18 @@ const CedarApolloProvider = ({
|
|
|
75
99
|
children
|
|
76
100
|
}) => {
|
|
77
101
|
const { cacheConfig, ...config } = graphQLClientConfig ?? {};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
const createCache = () => {
|
|
103
|
+
return new InMemoryCache({
|
|
104
|
+
fragments: fragmentRegistry,
|
|
105
|
+
...withParsedScalars(cacheConfig)
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
const cache = createCache().restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
|
|
82
109
|
return /* @__PURE__ */ React.createElement(FetchConfigProvider, { useAuth }, /* @__PURE__ */ React.createElement(
|
|
83
110
|
ApolloProviderWithFetchConfig,
|
|
84
111
|
{
|
|
85
112
|
config: { cache, ...config },
|
|
113
|
+
createCache,
|
|
86
114
|
useAuth,
|
|
87
115
|
logLevel
|
|
88
116
|
},
|
|
@@ -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"}
|