@cedarjs/web 6.0.0-canary.2663 → 6.0.0-canary.2664
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/ApolloProviderWithFetchConfig.d.ts +1 -1
- package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
- package/dist/apollo/ApolloProviderWithFetchConfig.js +23 -16
- package/dist/apollo/CedarApolloProvider.js +1 -1
- package/dist/apollo/CedarApolloProvider.test.js +38 -0
- 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/fragmentRegistry.test.js +67 -0
- package/dist/apollo/links.d.ts +4 -5
- package/dist/apollo/links.d.ts.map +1 -1
- package/dist/apollo/links.js +7 -7
- 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 +3 -3
- package/dist/apollo/suspense.d.ts.map +1 -1
- package/dist/apollo/suspense.js +1 -1
- 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/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 +2 -2
- package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts +1 -1
- package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
- package/dist/cjs/apollo/ApolloProviderWithFetchConfig.js +26 -21
- package/dist/cjs/apollo/CedarApolloProvider.js +2 -2
- package/dist/cjs/apollo/CedarApolloProvider.test.js +61 -0
- package/dist/cjs/apollo/apolloLinkTypes.d.ts +4 -4
- package/dist/cjs/apollo/apolloLinkTypes.d.ts.map +1 -1
- package/dist/cjs/apollo/fragmentRegistry.d.ts +3 -3
- package/dist/cjs/apollo/fragmentRegistry.d.ts.map +1 -1
- package/dist/cjs/apollo/fragmentRegistry.js +32 -18
- package/dist/cjs/apollo/fragmentRegistry.test.js +90 -0
- package/dist/cjs/apollo/links.d.ts +4 -5
- package/dist/cjs/apollo/links.d.ts.map +1 -1
- package/dist/cjs/apollo/links.js +12 -12
- package/dist/cjs/apollo/sseLink.d.ts +5 -8
- package/dist/cjs/apollo/sseLink.d.ts.map +1 -1
- package/dist/cjs/apollo/sseLink.js +11 -14
- package/dist/cjs/apollo/suspense.d.ts +3 -3
- package/dist/cjs/apollo/suspense.d.ts.map +1 -1
- package/dist/cjs/apollo/suspense.js +2 -2
- package/dist/cjs/apollo/useCache.d.ts +4 -6
- package/dist/cjs/apollo/useCache.d.ts.map +1 -1
- package/dist/cjs/apollo/useCache.js +2 -2
- package/dist/cjs/bundled/apollo-upload-client.d.ts +2 -2
- package/dist/cjs/bundled/apollo-upload-client.d.ts.map +1 -1
- package/dist/cjs/bundled/apollo-upload-client.js +1562 -1734
- package/dist/cjs/components/DevFatalErrorPage.d.ts +3 -3
- package/dist/cjs/components/DevFatalErrorPage.d.ts.map +1 -1
- package/dist/cjs/components/DevFatalErrorPage.js +2 -2
- package/dist/cjs/components/cell/CellErrorBoundary.d.ts +3 -3
- package/dist/cjs/components/cell/CellErrorBoundary.d.ts.map +1 -1
- package/dist/cjs/components/cell/cellTypes.d.ts +6 -5
- package/dist/cjs/components/cell/cellTypes.d.ts.map +1 -1
- package/dist/cjs/components/cell/createCell.d.ts.map +1 -1
- package/dist/cjs/components/cell/createCell.js +5 -4
- package/dist/cjs/components/cell/createCell.test.js +48 -48
- package/dist/cjs/components/cell/createFragmentCell.test.js +27 -30
- package/dist/cjs/components/cell/createSuspendingCell.d.ts.map +1 -1
- package/dist/cjs/components/cell/createSuspendingCell.js +7 -6
- package/dist/cjs/components/cell/createSuspendingCell.test.js +13 -13
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/components/DevFatalErrorPage.d.ts +3 -3
- package/dist/components/DevFatalErrorPage.d.ts.map +1 -1
- package/dist/components/DevFatalErrorPage.js +2 -2
- 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 +6 -5
- package/dist/components/cell/cellTypes.d.ts.map +1 -1
- package/dist/components/cell/createCell.d.ts.map +1 -1
- package/dist/components/cell/createCell.js +4 -3
- package/dist/components/cell/createCell.test.js +2 -2
- package/dist/components/cell/createFragmentCell.test.js +4 -7
- package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
- package/dist/components/cell/createSuspendingCell.js +4 -3
- package/dist/components/cell/createSuspendingCell.test.js +2 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/package.json +10 -9
|
@@ -4,7 +4,7 @@ import type { UseAuth } from '@cedarjs/auth';
|
|
|
4
4
|
import type { GraphQLClientConfigProp } from './apolloLinkTypes.js';
|
|
5
5
|
interface Props {
|
|
6
6
|
config: Omit<GraphQLClientConfigProp, 'cacheConfig' | 'cache'> & {
|
|
7
|
-
cache: ApolloCache
|
|
7
|
+
cache: ApolloCache;
|
|
8
8
|
};
|
|
9
9
|
useAuth?: UseAuth;
|
|
10
10
|
logLevel: ReturnType<typeof setLogVerbosity>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloProviderWithFetchConfig.d.ts","sourceRoot":"","sources":["../../src/apollo/ApolloProviderWithFetchConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ApolloProviderWithFetchConfig.d.ts","sourceRoot":"","sources":["../../src/apollo/ApolloProviderWithFetchConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAchF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAM5C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAoC7B,UAAU,KAAK;IACb,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG;QAC/D,KAAK,EAAE,WAAW,CAAA;KACnB,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC5C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,MAAM,EACN,QAAQ,EACR,OAAmB,EACnB,QAAQ,GACT,EAAE,KAAK,qBAuKP"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
3
|
ApolloClient,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
4
|
+
ApolloLink,
|
|
5
|
+
setLogVerbosity as apolloSetLogVerbosity,
|
|
6
|
+
split
|
|
7
|
+
} from "@apollo/client";
|
|
8
|
+
import { SetContextLink } from "@apollo/client/link/context";
|
|
9
|
+
import { PersistedQueryLink } from "@apollo/client/link/persisted-queries";
|
|
10
|
+
import { ApolloProvider } from "@apollo/client/react";
|
|
11
|
+
import { getMainDefinition } from "@apollo/client/utilities";
|
|
11
12
|
import { print } from "graphql/language/printer.js";
|
|
13
|
+
import { map } from "rxjs";
|
|
12
14
|
import { useNoAuth } from "@cedarjs/auth";
|
|
13
|
-
import {
|
|
15
|
+
import { UploadHttpLink } from "../bundled/apollo-upload-client.js";
|
|
14
16
|
import { useFetchConfig } from "../components/FetchConfigProvider.js";
|
|
15
17
|
import { ErrorBoundary } from "./ErrorBoundary.js";
|
|
16
18
|
import * as SSELinkExports from "./sseLink.js";
|
|
@@ -34,12 +36,14 @@ function ApolloProviderWithFetchConfig({
|
|
|
34
36
|
data.mostRecentRequest.operationKind = query?.kind.toString();
|
|
35
37
|
data.mostRecentRequest.variables = variables;
|
|
36
38
|
data.mostRecentRequest.query = query && print(operation.query);
|
|
37
|
-
return forward(operation).
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
return forward(operation).pipe(
|
|
40
|
+
map((result) => {
|
|
41
|
+
data.mostRecentResponse = result;
|
|
42
|
+
return result;
|
|
43
|
+
})
|
|
44
|
+
);
|
|
41
45
|
});
|
|
42
|
-
const withToken =
|
|
46
|
+
const withToken = new SetContextLink(async () => {
|
|
43
47
|
const token = await getToken();
|
|
44
48
|
return { token };
|
|
45
49
|
});
|
|
@@ -61,7 +65,7 @@ function ApolloProviderWithFetchConfig({
|
|
|
61
65
|
return forward(operation);
|
|
62
66
|
});
|
|
63
67
|
const { httpLinkConfig, link: cedarApolloLink, ...rest } = config ?? {};
|
|
64
|
-
const uploadLink =
|
|
68
|
+
const uploadLink = new UploadHttpLink({
|
|
65
69
|
uri,
|
|
66
70
|
...httpLinkConfig
|
|
67
71
|
});
|
|
@@ -83,8 +87,11 @@ function ApolloProviderWithFetchConfig({
|
|
|
83
87
|
const documentQuery = query;
|
|
84
88
|
return documentQuery?.["__meta__"]?.["hash"] !== void 0;
|
|
85
89
|
},
|
|
86
|
-
|
|
87
|
-
generateHash: (document) =>
|
|
90
|
+
new PersistedQueryLink({
|
|
91
|
+
generateHash: (document) => {
|
|
92
|
+
const documentWithMeta = document;
|
|
93
|
+
return documentWithMeta.__meta__?.hash ?? "";
|
|
94
|
+
}
|
|
88
95
|
}).concat(uploadOrSSELink),
|
|
89
96
|
uploadOrSSELink
|
|
90
97
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { InMemoryCache } from "@apollo/client
|
|
2
|
+
import { InMemoryCache } from "@apollo/client";
|
|
3
3
|
import { useNoAuth } from "@cedarjs/auth";
|
|
4
4
|
import { FetchConfigProvider } from "../components/FetchConfigProvider.js";
|
|
5
5
|
import { ApolloProviderWithFetchConfig } from "./ApolloProviderWithFetchConfig.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { gql } from "@apollo/client";
|
|
3
|
+
import { useQuery } from "@apollo/client/react";
|
|
4
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
5
|
+
import { vi, describe, test, expect } from "vitest";
|
|
6
|
+
import { CedarApolloProvider } from "./CedarApolloProvider.js";
|
|
7
|
+
globalThis.RWJS_API_GRAPHQL_URL = "https://example.com/graphql";
|
|
8
|
+
describe("CedarApolloProvider smoke test", () => {
|
|
9
|
+
test("renders children and runs a query through the full link chain", async () => {
|
|
10
|
+
const fetchMock = vi.fn(async () => {
|
|
11
|
+
return new Response(JSON.stringify({ data: { answer: 42 } }), {
|
|
12
|
+
headers: { "content-type": "application/json" }
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
16
|
+
const QUERY = gql`
|
|
17
|
+
query AnswerQuery {
|
|
18
|
+
answer
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
const Consumer = () => {
|
|
22
|
+
const { data, loading, error } = useQuery(QUERY);
|
|
23
|
+
if (error) {
|
|
24
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, "error: ", error.message);
|
|
25
|
+
}
|
|
26
|
+
if (loading) {
|
|
27
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, "loading");
|
|
28
|
+
}
|
|
29
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, "answer: ", data?.answer);
|
|
30
|
+
};
|
|
31
|
+
render(
|
|
32
|
+
/* @__PURE__ */ React.createElement(CedarApolloProvider, null, /* @__PURE__ */ React.createElement(Consumer, null))
|
|
33
|
+
);
|
|
34
|
+
await waitFor(() => screen.getByText("answer: 42"));
|
|
35
|
+
expect(fetchMock).toHaveBeenCalled();
|
|
36
|
+
vi.unstubAllGlobals();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApolloCache,
|
|
1
|
+
import type { ApolloCache, ApolloClient, ApolloLink, HttpLink, InMemoryCacheConfig } from '@apollo/client';
|
|
2
2
|
export type ApolloClientCacheConfig = InMemoryCacheConfig;
|
|
3
3
|
export type CedarApolloLinkName = 'withToken' | 'authMiddleware' | 'updateDataApolloLink' | 'httpLink';
|
|
4
4
|
export type CedarApolloLink<Name extends CedarApolloLinkName, Link extends ApolloLink = ApolloLink> = {
|
|
@@ -12,8 +12,8 @@ export type CedarApolloLinks = [
|
|
|
12
12
|
CedarApolloLink<'httpLink', ApolloLink | HttpLink>
|
|
13
13
|
];
|
|
14
14
|
export type CedarApolloLinkFactory = (links: CedarApolloLinks) => ApolloLink;
|
|
15
|
-
export type GraphQLClientConfigProp = Omit<
|
|
16
|
-
cache?: ApolloCache
|
|
15
|
+
export type GraphQLClientConfigProp = Omit<ApolloClient.Options, 'cache' | 'link'> & {
|
|
16
|
+
cache?: ApolloCache;
|
|
17
17
|
/**
|
|
18
18
|
* Configuration for Apollo Client's `InMemoryCache`.
|
|
19
19
|
* See https://www.apollographql.com/docs/react/caching/cache-configuration/.
|
|
@@ -31,7 +31,7 @@ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache'
|
|
|
31
31
|
* }}>
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
httpLinkConfig?:
|
|
34
|
+
httpLinkConfig?: HttpLink.Options;
|
|
35
35
|
/**
|
|
36
36
|
* Extend or overwrite `CedarApolloProvider`'s Apollo Link.
|
|
37
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apolloLinkTypes.d.ts","sourceRoot":"","sources":["../../src/apollo/apolloLinkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"apolloLinkTypes.d.ts","sourceRoot":"","sources":["../../src/apollo/apolloLinkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,mBAAmB,EACpB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAEzD,MAAM,MAAM,mBAAmB,GAC3B,WAAW,GACX,gBAAgB,GAChB,sBAAsB,GACtB,UAAU,CAAA;AAEd,MAAM,MAAM,eAAe,CACzB,IAAI,SAAS,mBAAmB,EAChC,IAAI,SAAS,UAAU,GAAG,UAAU,IAClC;IACF,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,CAAC,WAAW,CAAC;IAC5B,eAAe,CAAC,gBAAgB,CAAC;IACjC,eAAe,CAAC,sBAAsB,CAAC;IACvC,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,CAAC;CACnD,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,UAAU,CAAA;AAE5E,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,YAAY,CAAC,OAAO,EACpB,OAAO,GAAG,MAAM,CACjB,GAAG;IACF,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB;;;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,sBAAsB,CAAA;CAC3C,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { FragmentRegistryAPI } from '@apollo/client/cache';
|
|
2
|
+
import { useFragment as useApolloFragment } from '@apollo/client/react';
|
|
3
3
|
import type { DocumentNode } from 'graphql';
|
|
4
4
|
export interface FragmentHookOptions {
|
|
5
5
|
fragment: DocumentNode;
|
|
@@ -28,7 +28,7 @@ export type RegisterFragmentResult = {
|
|
|
28
28
|
fragment: DocumentNode;
|
|
29
29
|
typename: string;
|
|
30
30
|
getCacheKey: (id: FragmentIdentifier) => CacheKey;
|
|
31
|
-
useRegisteredFragment: <TData = any>(id: FragmentIdentifier) =>
|
|
31
|
+
useRegisteredFragment: <TData = any>(id: FragmentIdentifier) => useApolloFragment.Result<TData>;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* Read fragment data from Apollo Client's cache without firing a network
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragmentRegistry.d.ts","sourceRoot":"","sources":["../../src/apollo/fragmentRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"fragmentRegistry.d.ts","sourceRoot":"","sources":["../../src/apollo/fragmentRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE/D,OAAO,EAEL,WAAW,IAAI,iBAAiB,EACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,YAAY,EAA0B,MAAM,SAAS,CAAA;AAGnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,kBAAkB,CAAC,KAAK,GAAG,GAAG;IAC7C;;;OAGG;IACH,IAAI,EAAE,KAAK,GAAG,SAAS,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAA;AAEhD,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,kBAAkB,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,YAAY,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,CAAC,EAAE,EAAE,kBAAkB,KAAK,QAAQ,CAAA;IACjD,qBAAqB,EAAE,CAAC,KAAK,GAAG,GAAG,EACjC,EAAE,EAAE,kBAAkB,KACnB,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;CACrC,CAAA;AA4ED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,GAAG,GAAG,EACrC,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CAAC,KAAK,CAAC,CA6B3B;AAED;;;;;;;IAOI;AACJ,eAAO,MAAM,gBAAgB,EAAE,mBAA8C,CAAA;AAE7E;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,YAAY,EAAE,6BAE1D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,YAAY,KACrB,sBAqBF,CAAA"}
|
|
@@ -1,24 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { createFragmentRegistry } from "@apollo/client/cache";
|
|
2
|
+
import {
|
|
3
|
+
useApolloClient,
|
|
4
|
+
useFragment as useApolloFragment
|
|
5
|
+
} from "@apollo/client/react";
|
|
6
|
+
import { Kind } from "graphql";
|
|
7
|
+
const getFragmentDefinition = (fragment) => {
|
|
8
|
+
const definition = fragment.definitions.find(
|
|
9
|
+
(def) => def.kind === Kind.FRAGMENT_DEFINITION
|
|
10
|
+
);
|
|
11
|
+
if (!definition) {
|
|
12
|
+
throw new Error("The passed document contains no fragment definition");
|
|
13
|
+
}
|
|
14
|
+
return definition;
|
|
15
|
+
};
|
|
4
16
|
const getTypenameFromFragment = (fragment) => {
|
|
5
|
-
|
|
6
|
-
|
|
17
|
+
return getFragmentDefinition(fragment).typeCondition.name.value;
|
|
18
|
+
};
|
|
19
|
+
const getSingleFragmentName = (fragment) => {
|
|
20
|
+
const definitions = fragment.definitions.filter(
|
|
21
|
+
(def) => def.kind === Kind.FRAGMENT_DEFINITION
|
|
22
|
+
);
|
|
23
|
+
return definitions.length === 1 ? definitions[0].name.value : void 0;
|
|
7
24
|
};
|
|
8
25
|
const useRegisteredFragmentHook = (fragment, id) => {
|
|
9
26
|
const from = { __typename: getTypenameFromFragment(fragment), id };
|
|
10
|
-
return
|
|
27
|
+
return useApolloFragment({
|
|
11
28
|
fragment,
|
|
29
|
+
// The cache's fragment registry adds the definitions of any spread
|
|
30
|
+
// fragments to the document, so Apollo Client can't infer the fragment
|
|
31
|
+
// name from the document alone
|
|
32
|
+
fragmentName: getFragmentDefinition(fragment).name.value,
|
|
12
33
|
from
|
|
13
34
|
});
|
|
14
35
|
};
|
|
15
36
|
const UNIDENTIFIABLE_FRAGMENT_REF = "CedarUnidentifiableFragmentRef:_";
|
|
16
37
|
function useFragment(options) {
|
|
17
|
-
const client =
|
|
38
|
+
const client = useApolloClient();
|
|
18
39
|
const { from, ...restOptions } = options;
|
|
19
40
|
const cacheId = client.cache.identify(from);
|
|
20
|
-
const result =
|
|
41
|
+
const result = useApolloFragment({
|
|
21
42
|
...restOptions,
|
|
43
|
+
// The cache's fragment registry adds the definitions of any spread
|
|
44
|
+
// fragments to the document, so Apollo Client can't infer the fragment
|
|
45
|
+
// name from the document alone. When the passed document has more than
|
|
46
|
+
// one fragment definition of its own we pass `undefined` and let Apollo
|
|
47
|
+
// Client surface its "must provide fragmentName" error
|
|
48
|
+
fragmentName: restOptions.fragmentName ?? getSingleFragmentName(options.fragment),
|
|
22
49
|
// We identify the object ourselves (above) because passing an
|
|
23
50
|
// unidentifiable object to `useFragment` logs a warning and returns a
|
|
24
51
|
// useless `{ data: {}, complete: true }` result
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ApolloClient, ApolloLink, InMemoryCache, gql } from "@apollo/client";
|
|
3
|
+
import { ApolloProvider } from "@apollo/client/react";
|
|
4
|
+
import { render, screen } from "@testing-library/react";
|
|
5
|
+
import { describe, test } from "vitest";
|
|
6
|
+
import { fragmentRegistry, registerFragment } from "./fragmentRegistry.js";
|
|
7
|
+
const { useRegisteredFragment: useStallFragment } = registerFragment(gql`
|
|
8
|
+
fragment Stall_info on Stall {
|
|
9
|
+
id
|
|
10
|
+
name
|
|
11
|
+
}
|
|
12
|
+
`);
|
|
13
|
+
const { useRegisteredFragment: useFruitFragment } = registerFragment(gql`
|
|
14
|
+
fragment Fruit_info on Fruit {
|
|
15
|
+
id
|
|
16
|
+
name
|
|
17
|
+
isSeedless
|
|
18
|
+
stall {
|
|
19
|
+
...Stall_info
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`);
|
|
23
|
+
const StallInfo = ({ id }) => {
|
|
24
|
+
const { data: stall, complete } = useStallFragment(id);
|
|
25
|
+
return complete ? /* @__PURE__ */ React.createElement("p", null, "Stall Name: ", stall.name) : /* @__PURE__ */ React.createElement("p", null, "stall incomplete");
|
|
26
|
+
};
|
|
27
|
+
const FruitInfo = ({ id }) => {
|
|
28
|
+
const { data: fruit, complete } = useFruitFragment(id);
|
|
29
|
+
return complete ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h2", null, "Fruit Name: ", fruit.name), /* @__PURE__ */ React.createElement(StallInfo, { id: fruit.stall.id })) : /* @__PURE__ */ React.createElement("div", null, "fruit incomplete");
|
|
30
|
+
};
|
|
31
|
+
describe("registered fragments with nested spreads", () => {
|
|
32
|
+
test("reads complete data back from the cache", async () => {
|
|
33
|
+
const cache = new InMemoryCache({ fragments: fragmentRegistry });
|
|
34
|
+
const client = new ApolloClient({ cache, link: ApolloLink.empty() });
|
|
35
|
+
client.writeQuery({
|
|
36
|
+
query: gql`
|
|
37
|
+
query GetGroceries {
|
|
38
|
+
groceries {
|
|
39
|
+
... on Fruit {
|
|
40
|
+
...Fruit_info
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
data: {
|
|
46
|
+
groceries: [
|
|
47
|
+
{
|
|
48
|
+
__typename: "Fruit",
|
|
49
|
+
id: "1",
|
|
50
|
+
name: "Strawberries",
|
|
51
|
+
isSeedless: false,
|
|
52
|
+
stall: {
|
|
53
|
+
__typename: "Stall",
|
|
54
|
+
id: "s1",
|
|
55
|
+
name: "Pie Veggies"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
render(
|
|
62
|
+
/* @__PURE__ */ React.createElement(ApolloProvider, { client }, /* @__PURE__ */ React.createElement(FruitInfo, { id: "1" }))
|
|
63
|
+
);
|
|
64
|
+
screen.getByText("Fruit Name: Strawberries");
|
|
65
|
+
screen.getByText("Stall Name: Pie Veggies");
|
|
66
|
+
});
|
|
67
|
+
});
|
package/dist/apollo/links.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function createHttpLink(uri: string, httpLinkConfig: HttpOptions | undefined, cookieHeader?: string | null): HttpLink;
|
|
1
|
+
import { ApolloLink, HttpLink } from '@apollo/client';
|
|
2
|
+
import { SetContextLink } from '@apollo/client/link/context';
|
|
3
|
+
export declare function createHttpLink(uri: string, httpLinkConfig: HttpLink.Options | undefined, cookieHeader?: string | null): HttpLink;
|
|
5
4
|
export declare function createUpdateDataLink(): ApolloLink;
|
|
6
5
|
export declare function createAuthApolloLink(authProviderType: string, headersFromFetchProvider: {
|
|
7
6
|
'auth-provider'?: string | undefined;
|
|
8
7
|
authorization?: string | undefined;
|
|
9
8
|
} | undefined): ApolloLink;
|
|
10
|
-
export declare function createTokenLink(getToken: () => Promise<string | null>):
|
|
9
|
+
export declare function createTokenLink(getToken: () => Promise<string | null>): SetContextLink;
|
|
11
10
|
export declare function createFinalLink({ userConfiguredLink, defaultLinks, }: {
|
|
12
11
|
userConfiguredLink?: ApolloLink | RedwoodApolloLinkFactory;
|
|
13
12
|
defaultLinks: RedwoodApolloLinks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/apollo/links.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/apollo/links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAI5D,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,QAAQ,CAAC,OAAO,GAAG,SAAS,EAC5C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,YAc7B;AAeD,wBAAgB,oBAAoB,eAqBnC;AACD,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,MAAM,EACxB,wBAAwB,EACpB;IACE,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,GACD,SAAS,cA6Bd;AACD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,kBAMrE;AAED,wBAAgB,eAAe,CAAC,EAC9B,kBAAkB,EAClB,YAAY,GACb,EAAE;IACD,kBAAkB,CAAC,EAAE,UAAU,GAAG,wBAAwB,CAAA;IAC1D,YAAY,EAAE,kBAAkB,CAAA;CACjC,GAAG,UAAU,CAUb;AAID,MAAM,MAAM,iBAAiB,CAC3B,IAAI,SAAS,qBAAqB,EAClC,IAAI,SAAS,UAAU,GAAG,UAAU,IAClC;IACF,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAC7B,iBAAiB,CAAC,WAAW,CAAC,GAC9B,iBAAiB,CAAC,gBAAgB,CAAC,GACnC,iBAAiB,CAAC,kBAAkB,CAAC,GACrC,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAC1C,EAAE,CAAA;AAMH,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAA;AAC9C,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,IAAI,GAAG,KAAK,CAAA;AAC3E,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;AAExE,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,UAAU,CAAA"}
|
package/dist/apollo/links.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ApolloLink } from "@apollo/client/link/core/index.js";
|
|
4
|
-
import { HttpLink } from "@apollo/client/link/http/index.js";
|
|
1
|
+
import { ApolloLink, HttpLink } from "@apollo/client";
|
|
2
|
+
import { SetContextLink } from "@apollo/client/link/context";
|
|
5
3
|
import { print } from "graphql/language/printer.js";
|
|
4
|
+
import { Observable } from "rxjs";
|
|
6
5
|
function createHttpLink(uri, httpLinkConfig, cookieHeader) {
|
|
7
6
|
const headers = {};
|
|
8
7
|
if (cookieHeader) {
|
|
@@ -28,9 +27,9 @@ function enhanceError(operation, error) {
|
|
|
28
27
|
function createUpdateDataLink() {
|
|
29
28
|
return new ApolloLink((operation, forward) => {
|
|
30
29
|
return new Observable((observer) => {
|
|
31
|
-
forward(operation).subscribe({
|
|
30
|
+
const subscription = forward(operation).subscribe({
|
|
32
31
|
next(result) {
|
|
33
|
-
if (result.errors) {
|
|
32
|
+
if ("errors" in result && result.errors) {
|
|
34
33
|
result.errors.forEach((error) => {
|
|
35
34
|
enhanceError(operation, error);
|
|
36
35
|
});
|
|
@@ -42,6 +41,7 @@ function createUpdateDataLink() {
|
|
|
42
41
|
},
|
|
43
42
|
complete: observer.complete.bind(observer)
|
|
44
43
|
});
|
|
44
|
+
return () => subscription.unsubscribe();
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -67,7 +67,7 @@ function createAuthApolloLink(authProviderType, headersFromFetchProvider) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
function createTokenLink(getToken) {
|
|
70
|
-
return
|
|
70
|
+
return new SetContextLink(async () => {
|
|
71
71
|
const token = await getToken();
|
|
72
72
|
return { token };
|
|
73
73
|
});
|
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,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApolloClient as ApolloClientBase, ApolloLink, HttpLink, InMemoryCacheConfig, setLogVerbosity } from '@apollo/client';
|
|
3
3
|
import { InMemoryCache } from '@apollo/client-react-streaming';
|
|
4
4
|
import type { UseAuth } from '@cedarjs/auth';
|
|
5
5
|
import type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks } from './links.js';
|
|
6
6
|
export type ApolloClientCacheConfig = InMemoryCacheConfig;
|
|
7
7
|
export type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks, };
|
|
8
|
-
export type GraphQLClientConfigProp = Omit<
|
|
8
|
+
export type GraphQLClientConfigProp = Omit<ApolloClientBase.Options, 'cache' | 'link'> & {
|
|
9
9
|
cache?: InMemoryCache;
|
|
10
10
|
/**
|
|
11
11
|
* Configuration for Apollo Client's `InMemoryCache`.
|
|
@@ -24,7 +24,7 @@ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache'
|
|
|
24
24
|
* }}>
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
httpLinkConfig?:
|
|
27
|
+
httpLinkConfig?: HttpLink.Options;
|
|
28
28
|
/**
|
|
29
29
|
* Extend or overwrite `CedarApolloProvider`'s Apollo Link.
|
|
30
30
|
*
|
|
@@ -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,UAAU,EACV,QAAQ,EACR,mBAAmB,EACnB,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAEL,aAAa,EAEd,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAW5C,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;AAkFD,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,CA4BA,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB;0BAtCV,uBAAuB;cACnC,OAAO;eACN,UAAU,CAAC,OAAO,eAAe,CAAC;cACnC,KAAK,CAAC,SAAS;EAmC6B,CAAA"}
|
package/dist/apollo/suspense.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useContext } from "react";
|
|
3
|
-
import { setLogVerbosity as apolloSetLogVerbosity } from "@apollo/client
|
|
3
|
+
import { setLogVerbosity as apolloSetLogVerbosity } from "@apollo/client";
|
|
4
4
|
import {
|
|
5
5
|
ApolloClient,
|
|
6
6
|
InMemoryCache,
|
|
@@ -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
|
@@ -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"}
|
|
@@ -4,7 +4,7 @@ import type { UseAuth } from '@cedarjs/auth';
|
|
|
4
4
|
import type { GraphQLClientConfigProp } from './apolloLinkTypes.js';
|
|
5
5
|
interface Props {
|
|
6
6
|
config: Omit<GraphQLClientConfigProp, 'cacheConfig' | 'cache'> & {
|
|
7
|
-
cache: ApolloCache
|
|
7
|
+
cache: ApolloCache;
|
|
8
8
|
};
|
|
9
9
|
useAuth?: UseAuth;
|
|
10
10
|
logLevel: ReturnType<typeof setLogVerbosity>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApolloProviderWithFetchConfig.d.ts","sourceRoot":"","sources":["../../../src/apollo/ApolloProviderWithFetchConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ApolloProviderWithFetchConfig.d.ts","sourceRoot":"","sources":["../../../src/apollo/ApolloProviderWithFetchConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAchF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAM5C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,sBAAsB,CAAA;AAoC7B,UAAU,KAAK;IACb,MAAM,EAAE,IAAI,CAAC,uBAAuB,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG;QAC/D,KAAK,EAAE,WAAW,CAAA;KACnB,CAAA;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC5C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,MAAM,EACN,QAAQ,EACR,OAAmB,EACnB,QAAQ,GACT,EAAE,KAAK,qBAuKP"}
|