@cedarjs/web 7.0.0-canary.3259 → 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
package/apollo/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/cjs/apollo/index.js')
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ApolloCache, setLogVerbosity } from '@apollo/client';
|
|
3
3
|
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:
|
|
7
|
+
cache: ApolloCache<unknown>;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
* Builds a fresh cache from the same cache configuration and fragment
|
|
11
|
-
* registry as `config.cache`. Used to give every client
|
|
12
|
-
* `useCreateApolloClient` creates its own cache.
|
|
13
|
-
*/
|
|
14
|
-
createCache: () => InMemoryCache;
|
|
15
9
|
useAuth?: UseAuth;
|
|
16
10
|
logLevel: ReturnType<typeof setLogVerbosity>;
|
|
17
11
|
children: React.ReactNode;
|
|
18
12
|
}
|
|
19
|
-
export declare function ApolloProviderWithFetchConfig({ config,
|
|
13
|
+
export declare function ApolloProviderWithFetchConfig({ config, children, useAuth, logLevel, }: Props): React.JSX.Element;
|
|
20
14
|
export {};
|
|
21
15
|
//# sourceMappingURL=ApolloProviderWithFetchConfig.d.ts.map
|
|
@@ -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;AAIzB,OAAO,KAAK,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAYhF,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,CAAC,OAAO,CAAC,CAAA;KAC5B,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,qBAgKP"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
3
|
ApolloClient,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "@apollo/client";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { getMainDefinition } from "@apollo/client/utilities";
|
|
4
|
+
setLogVerbosity as apolloSetLogVerbosity
|
|
5
|
+
} from "@apollo/client/core/core.cjs";
|
|
6
|
+
import { setContext } from "@apollo/client/link/context/context.cjs";
|
|
7
|
+
import { ApolloLink, split } from "@apollo/client/link/core/core.cjs";
|
|
8
|
+
import { createPersistedQueryLink } from "@apollo/client/link/persisted-queries/persisted-queries.cjs";
|
|
9
|
+
import { ApolloProvider } from "@apollo/client/react/react.cjs";
|
|
10
|
+
import { getMainDefinition } from "@apollo/client/utilities/utilities.cjs";
|
|
12
11
|
import { print } from "graphql/language/printer.js";
|
|
13
|
-
import { map } from "rxjs";
|
|
14
12
|
import { useNoAuth } from "@cedarjs/auth";
|
|
15
|
-
import {
|
|
13
|
+
import { createUploadLink } from "../bundled/apollo-upload-client.js";
|
|
16
14
|
import { useFetchConfig } from "../components/FetchConfigProvider.js";
|
|
17
|
-
import { ApolloClientFactoryContext } from "./ApolloClientFactoryContext.js";
|
|
18
15
|
import { ErrorBoundary } from "./ErrorBoundary.js";
|
|
19
|
-
import { getOperationKind } from "./links.js";
|
|
20
16
|
import * as SSELinkExports from "./sseLink.js";
|
|
21
17
|
const { SSELink, isSubscription, isLiveQuery } = SSELinkExports;
|
|
22
18
|
function ApolloProviderWithFetchConfig({
|
|
23
19
|
config,
|
|
24
|
-
createCache,
|
|
25
20
|
children,
|
|
26
21
|
useAuth = useNoAuth,
|
|
27
22
|
logLevel
|
|
@@ -36,20 +31,15 @@ function ApolloProviderWithFetchConfig({
|
|
|
36
31
|
const { operationName, query, variables } = operation;
|
|
37
32
|
data.mostRecentRequest = {};
|
|
38
33
|
data.mostRecentRequest.operationName = operationName;
|
|
39
|
-
data.mostRecentRequest.operationKind =
|
|
40
|
-
query,
|
|
41
|
-
operationName
|
|
42
|
-
);
|
|
34
|
+
data.mostRecentRequest.operationKind = query?.kind.toString();
|
|
43
35
|
data.mostRecentRequest.variables = variables;
|
|
44
36
|
data.mostRecentRequest.query = query && print(operation.query);
|
|
45
|
-
return forward(operation).
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
);
|
|
37
|
+
return forward(operation).map((result) => {
|
|
38
|
+
data.mostRecentResponse = result;
|
|
39
|
+
return result;
|
|
40
|
+
});
|
|
51
41
|
});
|
|
52
|
-
const withToken =
|
|
42
|
+
const withToken = setContext(async () => {
|
|
53
43
|
const token = await getToken();
|
|
54
44
|
return { token };
|
|
55
45
|
});
|
|
@@ -71,7 +61,7 @@ function ApolloProviderWithFetchConfig({
|
|
|
71
61
|
return forward(operation);
|
|
72
62
|
});
|
|
73
63
|
const { httpLinkConfig, link: cedarApolloLink, ...rest } = config ?? {};
|
|
74
|
-
const uploadLink =
|
|
64
|
+
const uploadLink = createUploadLink({
|
|
75
65
|
uri,
|
|
76
66
|
...httpLinkConfig
|
|
77
67
|
});
|
|
@@ -93,11 +83,8 @@ function ApolloProviderWithFetchConfig({
|
|
|
93
83
|
const documentQuery = query;
|
|
94
84
|
return documentQuery?.["__meta__"]?.["hash"] !== void 0;
|
|
95
85
|
},
|
|
96
|
-
|
|
97
|
-
generateHash: (document) =>
|
|
98
|
-
const documentWithMeta = document;
|
|
99
|
-
return documentWithMeta.__meta__?.hash ?? "";
|
|
100
|
-
}
|
|
86
|
+
createPersistedQueryLink({
|
|
87
|
+
generateHash: (document) => document["__meta__"]["hash"]
|
|
101
88
|
}).concat(uploadOrSSELink),
|
|
102
89
|
uploadOrSSELink
|
|
103
90
|
);
|
|
@@ -112,45 +99,35 @@ function ApolloProviderWithFetchConfig({
|
|
|
112
99
|
if (typeof link === "function") {
|
|
113
100
|
link = link(cedarApolloLinks);
|
|
114
101
|
}
|
|
115
|
-
const defaultOptions = {
|
|
116
|
-
watchQuery: {
|
|
117
|
-
// The `fetchPolicy` we expect:
|
|
118
|
-
//
|
|
119
|
-
// > Apollo Client executes the full query against both the cache and
|
|
120
|
-
// > your GraphQL server.
|
|
121
|
-
// > The query automatically updates if the result of the server-side
|
|
122
|
-
// > query modifies cached fields.
|
|
123
|
-
//
|
|
124
|
-
// See https://www.apollographql.com/docs/react/data/queries/#cache-and-network.
|
|
125
|
-
fetchPolicy: "cache-and-network",
|
|
126
|
-
// So that Cells rerender when refetching.
|
|
127
|
-
// See https://www.apollographql.com/docs/react/data/queries/#inspecting-loading-states.
|
|
128
|
-
notifyOnNetworkStatusChange: true
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
102
|
const client = new ApolloClient({
|
|
132
|
-
|
|
103
|
+
// Default options for every Cell. Better to specify them here than in
|
|
104
|
+
// `beforeQuery` where it's too easy to overwrite them.
|
|
105
|
+
// See https://www.apollographql.com/docs/react/api/core/ApolloClient/#example-defaultoptions-object.
|
|
106
|
+
defaultOptions: {
|
|
107
|
+
watchQuery: {
|
|
108
|
+
// The `fetchPolicy` we expect:
|
|
109
|
+
//
|
|
110
|
+
// > Apollo Client executes the full query against both the cache and
|
|
111
|
+
// > your GraphQL server.
|
|
112
|
+
// > The query automatically updates if the result of the server-side
|
|
113
|
+
// > query modifies cached fields.
|
|
114
|
+
//
|
|
115
|
+
// See https://www.apollographql.com/docs/react/data/queries/#cache-and-network.
|
|
116
|
+
fetchPolicy: "cache-and-network",
|
|
117
|
+
// So that Cells rerender when refetching.
|
|
118
|
+
// See https://www.apollographql.com/docs/react/data/queries/#inspecting-loading-states.
|
|
119
|
+
notifyOnNetworkStatusChange: true
|
|
120
|
+
}
|
|
121
|
+
},
|
|
133
122
|
link,
|
|
134
123
|
...rest
|
|
135
124
|
});
|
|
136
|
-
const createApolloClient = (options) => {
|
|
137
|
-
const extraHeaders = options?.headers;
|
|
138
|
-
const withExtraHeaders = new SetContextLink((prevContext) => ({
|
|
139
|
-
headers: { ...prevContext.headers, ...extraHeaders }
|
|
140
|
-
}));
|
|
141
|
-
return new ApolloClient({
|
|
142
|
-
defaultOptions,
|
|
143
|
-
...rest,
|
|
144
|
-
cache: createCache(),
|
|
145
|
-
link: ApolloLink.from([withExtraHeaders, link])
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
125
|
const extendErrorAndRethrow = (error, _errorInfo) => {
|
|
149
126
|
error["mostRecentRequest"] = data.mostRecentRequest;
|
|
150
127
|
error["mostRecentResponse"] = data.mostRecentResponse;
|
|
151
128
|
throw error;
|
|
152
129
|
};
|
|
153
|
-
return /* @__PURE__ */ React.createElement(
|
|
130
|
+
return /* @__PURE__ */ React.createElement(ApolloProvider, { client }, /* @__PURE__ */ React.createElement(ErrorBoundary, { onError: extendErrorAndRethrow }, children));
|
|
154
131
|
}
|
|
155
132
|
export {
|
|
156
133
|
ApolloProviderWithFetchConfig
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import type { DocumentNode, setLogVerbosity } from '@apollo/client';
|
|
3
3
|
import type { UseAuth } from '@cedarjs/auth';
|
|
4
4
|
import type { GraphQLClientConfigProp } from './apolloLinkTypes.js';
|
|
5
|
-
import './typeOverrides.js';
|
|
6
5
|
export type { ApolloClientCacheConfig, CedarApolloLink, CedarApolloLinkFactory, CedarApolloLinkName, CedarApolloLinks, GraphQLClientConfigProp, } from './apolloLinkTypes.js';
|
|
7
6
|
interface Props {
|
|
8
7
|
graphQLClientConfig?: GraphQLClientConfigProp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CedarApolloProvider.d.ts","sourceRoot":"","sources":["../../src/apollo/CedarApolloProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAK5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAInE,
|
|
1
|
+
{"version":3,"file":"CedarApolloProvider.d.ts","sourceRoot":"","sources":["../../src/apollo/CedarApolloProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAK5C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAInE,YAAY,EACV,uBAAuB,EACvB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,sBAAsB,CAAA;AAE7B,UAAU,KAAK;IACb,mBAAmB,CAAC,EAAE,uBAAuB,CAAA;IAC7C,SAAS,CAAC,EAAE,YAAY,EAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,mBAAmB,EACnB,SAAS,EACT,OAAmB,EACnB,QAAkB,EAClB,QAAQ,GACT,EAAE,KAAK,qBA4BP"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { InMemoryCache } from "@apollo/client";
|
|
2
|
+
import { InMemoryCache } from "@apollo/client/cache/cache.cjs";
|
|
3
3
|
import { useNoAuth } from "@cedarjs/auth";
|
|
4
4
|
import { FetchConfigProvider } from "../components/FetchConfigProvider.js";
|
|
5
5
|
import { ApolloProviderWithFetchConfig } from "./ApolloProviderWithFetchConfig.js";
|
|
6
6
|
import { fragmentRegistry } from "./fragmentRegistry.js";
|
|
7
|
-
import { withParsedScalars } from "./parsedScalars.js";
|
|
8
|
-
import "./typeOverrides.js";
|
|
9
7
|
function CedarApolloProvider({
|
|
10
8
|
graphQLClientConfig,
|
|
11
9
|
fragments,
|
|
@@ -17,20 +15,15 @@ function CedarApolloProvider({
|
|
|
17
15
|
if (fragments) {
|
|
18
16
|
fragmentRegistry.register(...fragments);
|
|
19
17
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...withParsedScalars(cacheConfig)
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
const cache = createCache().restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
|
|
18
|
+
const cache = new InMemoryCache({
|
|
19
|
+
fragments: fragmentRegistry,
|
|
20
|
+
possibleTypes: cacheConfig?.possibleTypes,
|
|
21
|
+
...cacheConfig
|
|
22
|
+
}).restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
|
|
29
23
|
return /* @__PURE__ */ React.createElement(FetchConfigProvider, { useAuth }, /* @__PURE__ */ React.createElement(
|
|
30
24
|
ApolloProviderWithFetchConfig,
|
|
31
25
|
{
|
|
32
26
|
config: { cache, ...config },
|
|
33
|
-
createCache,
|
|
34
27
|
useAuth,
|
|
35
28
|
logLevel
|
|
36
29
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApolloCache, ApolloClientOptions, ApolloLink, HttpLink, HttpOptions, 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,13 +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
|
-
|
|
17
|
-
* Replace the `InMemoryCache` that `CedarApolloProvider` creates with one
|
|
18
|
-
* of your own. Apollo Client is told (via `TypeOverrides`) that its cache
|
|
19
|
-
* is always an `InMemoryCache`, so a cache passed here has to be one too.
|
|
20
|
-
*/
|
|
21
|
-
cache?: InMemoryCache;
|
|
15
|
+
export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache' | 'link'> & {
|
|
16
|
+
cache?: ApolloCache<unknown>;
|
|
22
17
|
/**
|
|
23
18
|
* Configuration for Apollo Client's `InMemoryCache`.
|
|
24
19
|
* See https://www.apollographql.com/docs/react/caching/cache-configuration/.
|
|
@@ -36,7 +31,7 @@ export type GraphQLClientConfigProp = Omit<ApolloClient.Options, 'cache' | 'link
|
|
|
36
31
|
* }}>
|
|
37
32
|
* ```
|
|
38
33
|
*/
|
|
39
|
-
httpLinkConfig?:
|
|
34
|
+
httpLinkConfig?: HttpOptions;
|
|
40
35
|
/**
|
|
41
36
|
* Extend or overwrite `CedarApolloProvider`'s Apollo Link.
|
|
42
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apolloLinkTypes.d.ts","sourceRoot":"","sources":["../../src/apollo/apolloLinkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"apolloLinkTypes.d.ts","sourceRoot":"","sources":["../../src/apollo/apolloLinkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,QAAQ,EACR,WAAW,EACX,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,mBAAmB,CAAC,OAAO,CAAC,EAC5B,OAAO,GAAG,MAAM,CACjB,GAAG;IACF,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAA;IACrC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,sBAAsB,CAAA;CAC3C,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { UseFragmentResult } from '@apollo/client';
|
|
2
|
+
import type { FragmentRegistryAPI } from '@apollo/client/cache/index.js';
|
|
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) => UseFragmentResult<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,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,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,KAAK,CAAC,CAAA;CAC9B,CAAA;AA8CD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,GAAG,GAAG,EACrC,OAAO,EAAE,mBAAmB,GAC3B,kBAAkB,CAAC,KAAK,CAAC,CAsB3B;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,51 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
};
|
|
1
|
+
import * as apolloClient from "@apollo/client";
|
|
2
|
+
import { createFragmentRegistry } from "@apollo/client/cache/cache.cjs";
|
|
3
|
+
import { getFragmentDefinitions } from "@apollo/client/utilities/utilities.cjs";
|
|
16
4
|
const getTypenameFromFragment = (fragment) => {
|
|
17
|
-
|
|
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;
|
|
5
|
+
const [definition] = getFragmentDefinitions(fragment);
|
|
6
|
+
return definition.typeCondition.name.value;
|
|
24
7
|
};
|
|
25
8
|
const useRegisteredFragmentHook = (fragment, id) => {
|
|
26
9
|
const from = { __typename: getTypenameFromFragment(fragment), id };
|
|
27
|
-
return
|
|
10
|
+
return apolloClient.useFragment({
|
|
28
11
|
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,
|
|
33
12
|
from
|
|
34
13
|
});
|
|
35
14
|
};
|
|
36
15
|
const UNIDENTIFIABLE_FRAGMENT_REF = "CedarUnidentifiableFragmentRef:_";
|
|
37
16
|
function useFragment(options) {
|
|
38
|
-
const client = useApolloClient();
|
|
17
|
+
const client = apolloClient.useApolloClient();
|
|
39
18
|
const { from, ...restOptions } = options;
|
|
40
19
|
const cacheId = client.cache.identify(from);
|
|
41
|
-
const result =
|
|
20
|
+
const result = apolloClient.useFragment({
|
|
42
21
|
...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),
|
|
49
22
|
// We identify the object ourselves (above) because passing an
|
|
50
23
|
// unidentifiable object to `useFragment` logs a warning and returns a
|
|
51
24
|
// useless `{ data: {}, complete: true }` result
|
package/dist/apollo/index.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { ApolloLink } from '@apollo/client';
|
|
2
|
-
import type { CreateApolloClientOptions } from './ApolloClientFactoryContext.js';
|
|
3
2
|
import { CedarApolloProvider } from './CedarApolloProvider.js';
|
|
4
3
|
import type { ApolloClientCacheConfig as CedarApolloClientCacheConfig, CedarApolloLink, CedarApolloLinkFactory, CedarApolloLinkName, CedarApolloLinks, GraphQLClientConfigProp as CedarGraphQLClientConfigProp } from './CedarApolloProvider.js';
|
|
5
4
|
import { fragmentRegistry, registerFragment, registerFragments } from './fragmentRegistry.js';
|
|
6
5
|
import { useCache } from './useCache.js';
|
|
7
|
-
import { useCreateApolloClient } from './useCreateApolloClient.js';
|
|
8
6
|
export type { CacheKey, FragmentIdentifier, RegisterFragmentResult, } from './fragmentRegistry.js';
|
|
9
|
-
export type { CreateApolloClientOptions };
|
|
10
7
|
export { useCache };
|
|
11
|
-
export { useCreateApolloClient };
|
|
12
8
|
export { fragmentRegistry, registerFragment, registerFragments };
|
|
13
9
|
/**
|
|
14
10
|
* @deprecated Import from `@cedarjs/web/apollo/CedarApolloProvider` instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/apollo/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/apollo/index.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
|
|
7
7
|
import { useCache } from "./useCache.js";
|
|
8
|
-
import { useCreateApolloClient } from "./useCreateApolloClient.js";
|
|
9
8
|
const RedwoodApolloProvider = CedarApolloProvider;
|
|
10
9
|
export {
|
|
11
10
|
RedwoodApolloProvider,
|
|
12
11
|
fragmentRegistry,
|
|
13
12
|
registerFragment,
|
|
14
13
|
registerFragments,
|
|
15
|
-
useCache
|
|
16
|
-
useCreateApolloClient
|
|
14
|
+
useCache
|
|
17
15
|
};
|
package/dist/apollo/links.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function createHttpLink(uri: string, httpLinkConfig: HttpLink.Options | undefined, cookieHeader?: string | null): HttpLink;
|
|
1
|
+
import type { HttpOptions } from '@apollo/client';
|
|
2
|
+
import { ApolloLink } from '@apollo/client/link/core/index.js';
|
|
3
|
+
import { HttpLink } from '@apollo/client/link/http/index.js';
|
|
4
|
+
export declare function createHttpLink(uri: string, httpLinkConfig: HttpOptions | undefined, cookieHeader?: string | null): HttpLink;
|
|
6
5
|
export declare function createUpdateDataLink(): ApolloLink;
|
|
7
6
|
export declare function createAuthApolloLink(authProviderType: string, headersFromFetchProvider: {
|
|
8
7
|
'auth-provider'?: string | undefined;
|
|
9
8
|
authorization?: string | undefined;
|
|
10
9
|
} | undefined): ApolloLink;
|
|
11
|
-
export declare function createTokenLink(getToken: () => Promise<string | null>):
|
|
10
|
+
export declare function createTokenLink(getToken: () => Promise<string | null>): ApolloLink;
|
|
12
11
|
export declare function createFinalLink({ userConfiguredLink, defaultLinks, }: {
|
|
13
12
|
userConfiguredLink?: ApolloLink | RedwoodApolloLinkFactory;
|
|
14
13
|
defaultLinks: RedwoodApolloLinks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/apollo/links.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|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AAC,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,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Observable } from "@apollo/client/core/index.js";
|
|
2
|
+
import { setContext } from "@apollo/client/link/context/index.js";
|
|
3
|
+
import { ApolloLink } from "@apollo/client/link/core/index.js";
|
|
4
|
+
import { HttpLink } from "@apollo/client/link/http/index.js";
|
|
4
5
|
import { print } from "graphql/language/printer.js";
|
|
5
|
-
import { Observable } from "rxjs";
|
|
6
|
-
function getOperationKind(query, operationName) {
|
|
7
|
-
return getOperationAST(query, operationName)?.operation;
|
|
8
|
-
}
|
|
9
6
|
function createHttpLink(uri, httpLinkConfig, cookieHeader) {
|
|
10
7
|
const headers = {};
|
|
11
8
|
if (cookieHeader) {
|
|
@@ -22,7 +19,7 @@ function enhanceError(operation, error) {
|
|
|
22
19
|
const { operationName, query, variables } = operation;
|
|
23
20
|
error.__RedwoodEnhancedError = {
|
|
24
21
|
operationName,
|
|
25
|
-
operationKind:
|
|
22
|
+
operationKind: query?.kind.toString(),
|
|
26
23
|
variables,
|
|
27
24
|
query: query && print(query)
|
|
28
25
|
};
|
|
@@ -31,9 +28,9 @@ function enhanceError(operation, error) {
|
|
|
31
28
|
function createUpdateDataLink() {
|
|
32
29
|
return new ApolloLink((operation, forward) => {
|
|
33
30
|
return new Observable((observer) => {
|
|
34
|
-
|
|
31
|
+
forward(operation).subscribe({
|
|
35
32
|
next(result) {
|
|
36
|
-
if (
|
|
33
|
+
if (result.errors) {
|
|
37
34
|
result.errors.forEach((error) => {
|
|
38
35
|
enhanceError(operation, error);
|
|
39
36
|
});
|
|
@@ -45,7 +42,6 @@ function createUpdateDataLink() {
|
|
|
45
42
|
},
|
|
46
43
|
complete: observer.complete.bind(observer)
|
|
47
44
|
});
|
|
48
|
-
return () => subscription.unsubscribe();
|
|
49
45
|
});
|
|
50
46
|
});
|
|
51
47
|
}
|
|
@@ -71,7 +67,7 @@ function createAuthApolloLink(authProviderType, headersFromFetchProvider) {
|
|
|
71
67
|
});
|
|
72
68
|
}
|
|
73
69
|
function createTokenLink(getToken) {
|
|
74
|
-
return
|
|
70
|
+
return setContext(async () => {
|
|
75
71
|
const token = await getToken();
|
|
76
72
|
return { token };
|
|
77
73
|
});
|
|
@@ -94,6 +90,5 @@ export {
|
|
|
94
90
|
createFinalLink,
|
|
95
91
|
createHttpLink,
|
|
96
92
|
createTokenLink,
|
|
97
|
-
createUpdateDataLink
|
|
98
|
-
getOperationKind
|
|
93
|
+
createUpdateDataLink
|
|
99
94
|
};
|
package/dist/apollo/sseLink.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { HttpOptions } from '@apollo/client';
|
|
2
|
+
import type { Operation, FetchResult } from '@apollo/client/core';
|
|
3
|
+
import { ApolloLink } from '@apollo/client/link/core/core.cjs';
|
|
4
|
+
import { Observable } from '@apollo/client/utilities/utilities.cjs';
|
|
3
5
|
import type { DefinitionNode } from 'graphql';
|
|
4
6
|
import type { ClientOptions } from 'graphql-sse';
|
|
5
|
-
import { Observable } from 'rxjs';
|
|
6
7
|
interface SSELinkOptions extends Partial<ClientOptions> {
|
|
7
8
|
url: string;
|
|
8
9
|
auth: {
|
|
9
10
|
authProviderType: string;
|
|
10
11
|
tokenFn: () => Promise<null | string>;
|
|
11
12
|
};
|
|
12
|
-
httpLinkConfig?:
|
|
13
|
+
httpLinkConfig?: HttpOptions;
|
|
13
14
|
headers?: Record<string, string>;
|
|
14
15
|
}
|
|
15
16
|
declare const isSubscription: (definition: DefinitionNode) => boolean;
|
|
@@ -20,7 +21,9 @@ declare const isLiveQuery: (definition: DefinitionNode) => boolean;
|
|
|
20
21
|
declare class SSELink extends ApolloLink {
|
|
21
22
|
private client;
|
|
22
23
|
constructor(options: SSELinkOptions);
|
|
23
|
-
request(operation:
|
|
24
|
+
request(operation: Operation & {
|
|
25
|
+
query?: any;
|
|
26
|
+
}): Observable<FetchResult>;
|
|
24
27
|
}
|
|
25
28
|
export { SSELink, isSubscription, isLiveQuery };
|
|
26
29
|
//# 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,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAA;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,aAAa,CAAA;AAE7E,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,WAAW,CAAA;IAC5B,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,SAAS,GAAG;QAAE,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE,GACrC,UAAU,CAAC,WAAW,CAAC;CAuB3B;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";
|
|
1
|
+
import { ApolloLink } from "@apollo/client/link/core/core.cjs";
|
|
2
|
+
import { Observable } from "@apollo/client/utilities/utilities.cjs";
|
|
2
3
|
import { Kind, OperationTypeNode, print } from "graphql";
|
|
3
4
|
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,13 +69,16 @@ class SSELink extends ApolloLink {
|
|
|
69
69
|
}
|
|
70
70
|
request(operation) {
|
|
71
71
|
return new Observable((sink) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
let request;
|
|
73
|
+
if (hasTrustedDocument(operation)) {
|
|
74
|
+
delete operation.query;
|
|
75
|
+
request = { ...operation };
|
|
76
|
+
} else {
|
|
77
|
+
request = {
|
|
78
|
+
...operation,
|
|
79
|
+
query: print(operation.query)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
79
82
|
return this.client.subscribe(request, {
|
|
80
83
|
next: sink.next.bind(sink),
|
|
81
84
|
complete: sink.complete.bind(sink),
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import { ApolloLink } from '@apollo/client';
|
|
2
|
+
import type { ApolloClientOptions, ApolloLink, HttpOptions, InMemoryCacheConfig, setLogVerbosity } from '@apollo/client';
|
|
4
3
|
import { InMemoryCache } from '@apollo/client-react-streaming';
|
|
5
|
-
import './typeOverrides.js';
|
|
6
4
|
import type { UseAuth } from '@cedarjs/auth';
|
|
7
5
|
import type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks } from './links.js';
|
|
8
6
|
export type ApolloClientCacheConfig = InMemoryCacheConfig;
|
|
9
7
|
export type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks, };
|
|
10
|
-
export type GraphQLClientConfigProp = Omit<
|
|
8
|
+
export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache' | 'link'> & {
|
|
11
9
|
cache?: InMemoryCache;
|
|
12
10
|
/**
|
|
13
11
|
* Configuration for Apollo Client's `InMemoryCache`.
|
|
@@ -26,7 +24,7 @@ export type GraphQLClientConfigProp = Omit<ApolloClientBase.Options, 'cache' | '
|
|
|
26
24
|
* }}>
|
|
27
25
|
* ```
|
|
28
26
|
*/
|
|
29
|
-
httpLinkConfig?:
|
|
27
|
+
httpLinkConfig?: HttpOptions;
|
|
30
28
|
/**
|
|
31
29
|
* Extend or overwrite `CedarApolloProvider`'s Apollo Link.
|
|
32
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,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