@cedarjs/web 6.0.0-canary.2663 → 6.0.0-canary.2665

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.
Files changed (87) hide show
  1. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts +1 -1
  2. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
  3. package/dist/apollo/ApolloProviderWithFetchConfig.js +23 -16
  4. package/dist/apollo/CedarApolloProvider.js +1 -1
  5. package/dist/apollo/CedarApolloProvider.test.js +38 -0
  6. package/dist/apollo/apolloLinkTypes.d.ts +4 -4
  7. package/dist/apollo/apolloLinkTypes.d.ts.map +1 -1
  8. package/dist/apollo/fragmentRegistry.d.ts +3 -3
  9. package/dist/apollo/fragmentRegistry.d.ts.map +1 -1
  10. package/dist/apollo/fragmentRegistry.js +35 -8
  11. package/dist/apollo/fragmentRegistry.test.js +67 -0
  12. package/dist/apollo/links.d.ts +4 -5
  13. package/dist/apollo/links.d.ts.map +1 -1
  14. package/dist/apollo/links.js +7 -7
  15. package/dist/apollo/sseLink.d.ts +5 -8
  16. package/dist/apollo/sseLink.d.ts.map +1 -1
  17. package/dist/apollo/sseLink.js +9 -12
  18. package/dist/apollo/suspense.d.ts +3 -3
  19. package/dist/apollo/suspense.d.ts.map +1 -1
  20. package/dist/apollo/suspense.js +1 -1
  21. package/dist/apollo/useCache.d.ts +4 -6
  22. package/dist/apollo/useCache.d.ts.map +1 -1
  23. package/dist/apollo/useCache.js +1 -1
  24. package/dist/bundled/apollo-upload-client.d.ts +2 -2
  25. package/dist/bundled/apollo-upload-client.d.ts.map +1 -1
  26. package/dist/bundled/apollo-upload-client.js +2 -2
  27. package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts +1 -1
  28. package/dist/cjs/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
  29. package/dist/cjs/apollo/ApolloProviderWithFetchConfig.js +26 -21
  30. package/dist/cjs/apollo/CedarApolloProvider.js +2 -2
  31. package/dist/cjs/apollo/CedarApolloProvider.test.js +61 -0
  32. package/dist/cjs/apollo/apolloLinkTypes.d.ts +4 -4
  33. package/dist/cjs/apollo/apolloLinkTypes.d.ts.map +1 -1
  34. package/dist/cjs/apollo/fragmentRegistry.d.ts +3 -3
  35. package/dist/cjs/apollo/fragmentRegistry.d.ts.map +1 -1
  36. package/dist/cjs/apollo/fragmentRegistry.js +32 -18
  37. package/dist/cjs/apollo/fragmentRegistry.test.js +90 -0
  38. package/dist/cjs/apollo/links.d.ts +4 -5
  39. package/dist/cjs/apollo/links.d.ts.map +1 -1
  40. package/dist/cjs/apollo/links.js +12 -12
  41. package/dist/cjs/apollo/sseLink.d.ts +5 -8
  42. package/dist/cjs/apollo/sseLink.d.ts.map +1 -1
  43. package/dist/cjs/apollo/sseLink.js +11 -14
  44. package/dist/cjs/apollo/suspense.d.ts +3 -3
  45. package/dist/cjs/apollo/suspense.d.ts.map +1 -1
  46. package/dist/cjs/apollo/suspense.js +2 -2
  47. package/dist/cjs/apollo/useCache.d.ts +4 -6
  48. package/dist/cjs/apollo/useCache.d.ts.map +1 -1
  49. package/dist/cjs/apollo/useCache.js +2 -2
  50. package/dist/cjs/bundled/apollo-upload-client.d.ts +2 -2
  51. package/dist/cjs/bundled/apollo-upload-client.d.ts.map +1 -1
  52. package/dist/cjs/bundled/apollo-upload-client.js +1562 -1734
  53. package/dist/cjs/components/DevFatalErrorPage.d.ts +3 -3
  54. package/dist/cjs/components/DevFatalErrorPage.d.ts.map +1 -1
  55. package/dist/cjs/components/DevFatalErrorPage.js +2 -2
  56. package/dist/cjs/components/cell/CellErrorBoundary.d.ts +3 -3
  57. package/dist/cjs/components/cell/CellErrorBoundary.d.ts.map +1 -1
  58. package/dist/cjs/components/cell/cellTypes.d.ts +6 -5
  59. package/dist/cjs/components/cell/cellTypes.d.ts.map +1 -1
  60. package/dist/cjs/components/cell/createCell.d.ts.map +1 -1
  61. package/dist/cjs/components/cell/createCell.js +5 -4
  62. package/dist/cjs/components/cell/createCell.test.js +48 -48
  63. package/dist/cjs/components/cell/createFragmentCell.test.js +27 -30
  64. package/dist/cjs/components/cell/createSuspendingCell.d.ts.map +1 -1
  65. package/dist/cjs/components/cell/createSuspendingCell.js +7 -6
  66. package/dist/cjs/components/cell/createSuspendingCell.test.js +13 -13
  67. package/dist/cjs/index.d.ts +1 -1
  68. package/dist/cjs/index.d.ts.map +1 -1
  69. package/dist/cjs/index.js +4 -4
  70. package/dist/components/DevFatalErrorPage.d.ts +3 -3
  71. package/dist/components/DevFatalErrorPage.d.ts.map +1 -1
  72. package/dist/components/DevFatalErrorPage.js +2 -2
  73. package/dist/components/cell/CellErrorBoundary.d.ts +3 -3
  74. package/dist/components/cell/CellErrorBoundary.d.ts.map +1 -1
  75. package/dist/components/cell/cellTypes.d.ts +6 -5
  76. package/dist/components/cell/cellTypes.d.ts.map +1 -1
  77. package/dist/components/cell/createCell.d.ts.map +1 -1
  78. package/dist/components/cell/createCell.js +4 -3
  79. package/dist/components/cell/createCell.test.js +2 -2
  80. package/dist/components/cell/createFragmentCell.test.js +4 -7
  81. package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
  82. package/dist/components/cell/createSuspendingCell.js +4 -3
  83. package/dist/components/cell/createSuspendingCell.test.js +2 -5
  84. package/dist/index.d.ts +1 -1
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +1 -5
  87. package/package.json +10 -9
@@ -32,13 +32,13 @@ __export(ApolloProviderWithFetchConfig_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(ApolloProviderWithFetchConfig_exports);
34
34
  var import_react = __toESM(require("react"), 1);
35
- var import_core = require("@apollo/client/core/core.cjs");
36
- var import_context = require("@apollo/client/link/context/context.cjs");
37
- var import_core2 = require("@apollo/client/link/core/core.cjs");
38
- var import_persisted_queries = require("@apollo/client/link/persisted-queries/persisted-queries.cjs");
39
- var import_react2 = require("@apollo/client/react/react.cjs");
40
- var import_utilities = require("@apollo/client/utilities/utilities.cjs");
35
+ var import_client = require("@apollo/client");
36
+ var import_context = require("@apollo/client/link/context");
37
+ var import_persisted_queries = require("@apollo/client/link/persisted-queries");
38
+ var import_react2 = require("@apollo/client/react");
39
+ var import_utilities = require("@apollo/client/utilities");
41
40
  var import_printer = require("graphql/language/printer.js");
41
+ var import_rxjs = require("rxjs");
42
42
  var import_auth = require("@cedarjs/auth");
43
43
  var import_apollo_upload_client = require("../bundled/apollo-upload-client.js");
44
44
  var import_FetchConfigProvider = require("../components/FetchConfigProvider.js");
@@ -51,30 +51,32 @@ function ApolloProviderWithFetchConfig({
51
51
  useAuth = import_auth.useNoAuth,
52
52
  logLevel
53
53
  }) {
54
- (0, import_core.setLogVerbosity)(logLevel);
54
+ (0, import_client.setLogVerbosity)(logLevel);
55
55
  const { getToken, type: authProviderType } = useAuth();
56
56
  const data = {
57
57
  mostRecentRequest: void 0,
58
58
  mostRecentResponse: void 0
59
59
  };
60
- const updateDataApolloLink = new import_core2.ApolloLink((operation, forward) => {
60
+ const updateDataApolloLink = new import_client.ApolloLink((operation, forward) => {
61
61
  const { operationName, query, variables } = operation;
62
62
  data.mostRecentRequest = {};
63
63
  data.mostRecentRequest.operationName = operationName;
64
64
  data.mostRecentRequest.operationKind = query?.kind.toString();
65
65
  data.mostRecentRequest.variables = variables;
66
66
  data.mostRecentRequest.query = query && (0, import_printer.print)(operation.query);
67
- return forward(operation).map((result) => {
68
- data.mostRecentResponse = result;
69
- return result;
70
- });
67
+ return forward(operation).pipe(
68
+ (0, import_rxjs.map)((result) => {
69
+ data.mostRecentResponse = result;
70
+ return result;
71
+ })
72
+ );
71
73
  });
72
- const withToken = (0, import_context.setContext)(async () => {
74
+ const withToken = new import_context.SetContextLink(async () => {
73
75
  const token = await getToken();
74
76
  return { token };
75
77
  });
76
78
  const { headers, uri } = (0, import_FetchConfigProvider.useFetchConfig)();
77
- const authMiddleware = new import_core2.ApolloLink((operation, forward) => {
79
+ const authMiddleware = new import_client.ApolloLink((operation, forward) => {
78
80
  const { token } = operation.getContext();
79
81
  const authHeaders = token ? {
80
82
  "auth-provider": authProviderType,
@@ -91,11 +93,11 @@ function ApolloProviderWithFetchConfig({
91
93
  return forward(operation);
92
94
  });
93
95
  const { httpLinkConfig, link: cedarApolloLink, ...rest } = config ?? {};
94
- const uploadLink = (0, import_apollo_upload_client.createUploadLink)({
96
+ const uploadLink = new import_apollo_upload_client.UploadHttpLink({
95
97
  uri,
96
98
  ...httpLinkConfig
97
99
  });
98
- const uploadOrSSELink = typeof SSELink !== "undefined" ? (0, import_core2.split)(
100
+ const uploadOrSSELink = typeof SSELink !== "undefined" ? (0, import_client.split)(
99
101
  ({ query }) => {
100
102
  const definition = (0, import_utilities.getMainDefinition)(query);
101
103
  return isSubscription(definition) || isLiveQuery(definition);
@@ -108,13 +110,16 @@ function ApolloProviderWithFetchConfig({
108
110
  }),
109
111
  uploadLink
110
112
  ) : uploadLink;
111
- const terminatingLink = (0, import_core2.split)(
113
+ const terminatingLink = (0, import_client.split)(
112
114
  ({ query }) => {
113
115
  const documentQuery = query;
114
116
  return documentQuery?.["__meta__"]?.["hash"] !== void 0;
115
117
  },
116
- (0, import_persisted_queries.createPersistedQueryLink)({
117
- generateHash: (document) => document["__meta__"]["hash"]
118
+ new import_persisted_queries.PersistedQueryLink({
119
+ generateHash: (document) => {
120
+ const documentWithMeta = document;
121
+ return documentWithMeta.__meta__?.hash ?? "";
122
+ }
118
123
  }).concat(uploadOrSSELink),
119
124
  uploadOrSSELink
120
125
  );
@@ -125,11 +130,11 @@ function ApolloProviderWithFetchConfig({
125
130
  { name: "httpLink", link: terminatingLink }
126
131
  ];
127
132
  let link = cedarApolloLink;
128
- link ??= import_core2.ApolloLink.from(cedarApolloLinks.map((l) => l.link));
133
+ link ??= import_client.ApolloLink.from(cedarApolloLinks.map((l) => l.link));
129
134
  if (typeof link === "function") {
130
135
  link = link(cedarApolloLinks);
131
136
  }
132
- const client = new import_core.ApolloClient({
137
+ const client = new import_client.ApolloClient({
133
138
  // Default options for every Cell. Better to specify them here than in
134
139
  // `beforeQuery` where it's too easy to overwrite them.
135
140
  // See https://www.apollographql.com/docs/react/api/core/ApolloClient/#example-defaultoptions-object.
@@ -32,7 +32,7 @@ __export(CedarApolloProvider_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(CedarApolloProvider_exports);
34
34
  var import_react = __toESM(require("react"), 1);
35
- var import_cache = require("@apollo/client/cache/cache.cjs");
35
+ var import_client = require("@apollo/client");
36
36
  var import_auth = require("@cedarjs/auth");
37
37
  var import_FetchConfigProvider = require("../components/FetchConfigProvider.js");
38
38
  var import_ApolloProviderWithFetchConfig = require("./ApolloProviderWithFetchConfig.js");
@@ -48,7 +48,7 @@ function CedarApolloProvider({
48
48
  if (fragments) {
49
49
  import_fragmentRegistry.fragmentRegistry.register(...fragments);
50
50
  }
51
- const cache = new import_cache.InMemoryCache({
51
+ const cache = new import_client.InMemoryCache({
52
52
  fragments: import_fragmentRegistry.fragmentRegistry,
53
53
  possibleTypes: cacheConfig?.possibleTypes,
54
54
  ...cacheConfig
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_react = __toESM(require("react"), 1);
25
+ var import_client = require("@apollo/client");
26
+ var import_react2 = require("@apollo/client/react");
27
+ var import_react3 = require("@testing-library/react");
28
+ var import_vitest = require("vitest");
29
+ var import_CedarApolloProvider = require("./CedarApolloProvider.js");
30
+ globalThis.RWJS_API_GRAPHQL_URL = "https://example.com/graphql";
31
+ (0, import_vitest.describe)("CedarApolloProvider smoke test", () => {
32
+ (0, import_vitest.test)("renders children and runs a query through the full link chain", async () => {
33
+ const fetchMock = import_vitest.vi.fn(async () => {
34
+ return new Response(JSON.stringify({ data: { answer: 42 } }), {
35
+ headers: { "content-type": "application/json" }
36
+ });
37
+ });
38
+ import_vitest.vi.stubGlobal("fetch", fetchMock);
39
+ const QUERY = import_client.gql`
40
+ query AnswerQuery {
41
+ answer
42
+ }
43
+ `;
44
+ const Consumer = () => {
45
+ const { data, loading, error } = (0, import_react2.useQuery)(QUERY);
46
+ if (error) {
47
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, "error: ", error.message);
48
+ }
49
+ if (loading) {
50
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, "loading");
51
+ }
52
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, "answer: ", data?.answer);
53
+ };
54
+ (0, import_react3.render)(
55
+ /* @__PURE__ */ import_react.default.createElement(import_CedarApolloProvider.CedarApolloProvider, null, /* @__PURE__ */ import_react.default.createElement(Consumer, null))
56
+ );
57
+ await (0, import_react3.waitFor)(() => import_react3.screen.getByText("answer: 42"));
58
+ (0, import_vitest.expect)(fetchMock).toHaveBeenCalled();
59
+ import_vitest.vi.unstubAllGlobals();
60
+ });
61
+ });
@@ -1,4 +1,4 @@
1
- import type { ApolloCache, ApolloClientOptions, ApolloLink, HttpLink, HttpOptions, InMemoryCacheConfig } from '@apollo/client';
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<ApolloClientOptions<unknown>, 'cache' | 'link'> & {
16
- cache?: ApolloCache<unknown>;
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?: HttpOptions;
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,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,U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,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 { UseFragmentResult } from '@apollo/client';
2
- import type { FragmentRegistryAPI } from '@apollo/client/cache/index.js';
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) => UseFragmentResult<TData>;
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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;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,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var fragmentRegistry_exports = {};
30
20
  __export(fragmentRegistry_exports, {
@@ -34,27 +24,51 @@ __export(fragmentRegistry_exports, {
34
24
  useFragment: () => useFragment
35
25
  });
36
26
  module.exports = __toCommonJS(fragmentRegistry_exports);
37
- var apolloClient = __toESM(require("@apollo/client"), 1);
38
- var import_cache = require("@apollo/client/cache/cache.cjs");
39
- var import_utilities = require("@apollo/client/utilities/utilities.cjs");
27
+ var import_cache = require("@apollo/client/cache");
28
+ var import_react = require("@apollo/client/react");
29
+ var import_graphql = require("graphql");
30
+ const getFragmentDefinition = (fragment) => {
31
+ const definition = fragment.definitions.find(
32
+ (def) => def.kind === import_graphql.Kind.FRAGMENT_DEFINITION
33
+ );
34
+ if (!definition) {
35
+ throw new Error("The passed document contains no fragment definition");
36
+ }
37
+ return definition;
38
+ };
40
39
  const getTypenameFromFragment = (fragment) => {
41
- const [definition] = (0, import_utilities.getFragmentDefinitions)(fragment);
42
- return definition.typeCondition.name.value;
40
+ return getFragmentDefinition(fragment).typeCondition.name.value;
41
+ };
42
+ const getSingleFragmentName = (fragment) => {
43
+ const definitions = fragment.definitions.filter(
44
+ (def) => def.kind === import_graphql.Kind.FRAGMENT_DEFINITION
45
+ );
46
+ return definitions.length === 1 ? definitions[0].name.value : void 0;
43
47
  };
44
48
  const useRegisteredFragmentHook = (fragment, id) => {
45
49
  const from = { __typename: getTypenameFromFragment(fragment), id };
46
- return apolloClient.useFragment({
50
+ return (0, import_react.useFragment)({
47
51
  fragment,
52
+ // The cache's fragment registry adds the definitions of any spread
53
+ // fragments to the document, so Apollo Client can't infer the fragment
54
+ // name from the document alone
55
+ fragmentName: getFragmentDefinition(fragment).name.value,
48
56
  from
49
57
  });
50
58
  };
51
59
  const UNIDENTIFIABLE_FRAGMENT_REF = "CedarUnidentifiableFragmentRef:_";
52
60
  function useFragment(options) {
53
- const client = apolloClient.useApolloClient();
61
+ const client = (0, import_react.useApolloClient)();
54
62
  const { from, ...restOptions } = options;
55
63
  const cacheId = client.cache.identify(from);
56
- const result = apolloClient.useFragment({
64
+ const result = (0, import_react.useFragment)({
57
65
  ...restOptions,
66
+ // The cache's fragment registry adds the definitions of any spread
67
+ // fragments to the document, so Apollo Client can't infer the fragment
68
+ // name from the document alone. When the passed document has more than
69
+ // one fragment definition of its own we pass `undefined` and let Apollo
70
+ // Client surface its "must provide fragmentName" error
71
+ fragmentName: restOptions.fragmentName ?? getSingleFragmentName(options.fragment),
58
72
  // We identify the object ourselves (above) because passing an
59
73
  // unidentifiable object to `useFragment` logs a warning and returns a
60
74
  // useless `{ data: {}, complete: true }` result
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_react = __toESM(require("react"), 1);
25
+ var import_client = require("@apollo/client");
26
+ var import_react2 = require("@apollo/client/react");
27
+ var import_react3 = require("@testing-library/react");
28
+ var import_vitest = require("vitest");
29
+ var import_fragmentRegistry = require("./fragmentRegistry.js");
30
+ const { useRegisteredFragment: useStallFragment } = (0, import_fragmentRegistry.registerFragment)(import_client.gql`
31
+ fragment Stall_info on Stall {
32
+ id
33
+ name
34
+ }
35
+ `);
36
+ const { useRegisteredFragment: useFruitFragment } = (0, import_fragmentRegistry.registerFragment)(import_client.gql`
37
+ fragment Fruit_info on Fruit {
38
+ id
39
+ name
40
+ isSeedless
41
+ stall {
42
+ ...Stall_info
43
+ }
44
+ }
45
+ `);
46
+ const StallInfo = ({ id }) => {
47
+ const { data: stall, complete } = useStallFragment(id);
48
+ return complete ? /* @__PURE__ */ import_react.default.createElement("p", null, "Stall Name: ", stall.name) : /* @__PURE__ */ import_react.default.createElement("p", null, "stall incomplete");
49
+ };
50
+ const FruitInfo = ({ id }) => {
51
+ const { data: fruit, complete } = useFruitFragment(id);
52
+ return complete ? /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("h2", null, "Fruit Name: ", fruit.name), /* @__PURE__ */ import_react.default.createElement(StallInfo, { id: fruit.stall.id })) : /* @__PURE__ */ import_react.default.createElement("div", null, "fruit incomplete");
53
+ };
54
+ (0, import_vitest.describe)("registered fragments with nested spreads", () => {
55
+ (0, import_vitest.test)("reads complete data back from the cache", async () => {
56
+ const cache = new import_client.InMemoryCache({ fragments: import_fragmentRegistry.fragmentRegistry });
57
+ const client = new import_client.ApolloClient({ cache, link: import_client.ApolloLink.empty() });
58
+ client.writeQuery({
59
+ query: import_client.gql`
60
+ query GetGroceries {
61
+ groceries {
62
+ ... on Fruit {
63
+ ...Fruit_info
64
+ }
65
+ }
66
+ }
67
+ `,
68
+ data: {
69
+ groceries: [
70
+ {
71
+ __typename: "Fruit",
72
+ id: "1",
73
+ name: "Strawberries",
74
+ isSeedless: false,
75
+ stall: {
76
+ __typename: "Stall",
77
+ id: "s1",
78
+ name: "Pie Veggies"
79
+ }
80
+ }
81
+ ]
82
+ }
83
+ });
84
+ (0, import_react3.render)(
85
+ /* @__PURE__ */ import_react.default.createElement(import_react2.ApolloProvider, { client }, /* @__PURE__ */ import_react.default.createElement(FruitInfo, { id: "1" }))
86
+ );
87
+ import_react3.screen.getByText("Fruit Name: Strawberries");
88
+ import_react3.screen.getByText("Stall Name: Pie Veggies");
89
+ });
90
+ });
@@ -1,13 +1,12 @@
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;
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>): ApolloLink;
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,KAAK,EAAE,WAAW,EAAa,MAAM,gBAAgB,CAAA;AAG5D,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAA;AAG5D,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,WAAW,GAAG,SAAS,EACvC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,YAc7B;AAeD,wBAAgB,oBAAoB,eAmBnC;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,SA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AM,wBAAwB,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,UAAU,CAAA"}
@@ -25,17 +25,16 @@ __export(links_exports, {
25
25
  createUpdateDataLink: () => createUpdateDataLink
26
26
  });
27
27
  module.exports = __toCommonJS(links_exports);
28
- var import_core = require("@apollo/client/core/index.js");
29
- var import_context = require("@apollo/client/link/context/index.js");
30
- var import_core2 = require("@apollo/client/link/core/index.js");
31
- var import_http = require("@apollo/client/link/http/index.js");
28
+ var import_client = require("@apollo/client");
29
+ var import_context = require("@apollo/client/link/context");
32
30
  var import_printer = require("graphql/language/printer.js");
31
+ var import_rxjs = require("rxjs");
33
32
  function createHttpLink(uri, httpLinkConfig, cookieHeader) {
34
33
  const headers = {};
35
34
  if (cookieHeader) {
36
35
  headers.cookie = cookieHeader;
37
36
  }
38
- return new import_http.HttpLink({
37
+ return new import_client.HttpLink({
39
38
  uri,
40
39
  credentials: "include",
41
40
  ...httpLinkConfig,
@@ -53,11 +52,11 @@ function enhanceError(operation, error) {
53
52
  return error;
54
53
  }
55
54
  function createUpdateDataLink() {
56
- return new import_core2.ApolloLink((operation, forward) => {
57
- return new import_core.Observable((observer) => {
58
- forward(operation).subscribe({
55
+ return new import_client.ApolloLink((operation, forward) => {
56
+ return new import_rxjs.Observable((observer) => {
57
+ const subscription = forward(operation).subscribe({
59
58
  next(result) {
60
- if (result.errors) {
59
+ if ("errors" in result && result.errors) {
61
60
  result.errors.forEach((error) => {
62
61
  enhanceError(operation, error);
63
62
  });
@@ -69,11 +68,12 @@ function createUpdateDataLink() {
69
68
  },
70
69
  complete: observer.complete.bind(observer)
71
70
  });
71
+ return () => subscription.unsubscribe();
72
72
  });
73
73
  });
74
74
  }
75
75
  function createAuthApolloLink(authProviderType, headersFromFetchProvider) {
76
- return new import_core2.ApolloLink((operation, forward) => {
76
+ return new import_client.ApolloLink((operation, forward) => {
77
77
  const { token } = operation.getContext();
78
78
  const authHeaders = token ? {
79
79
  "auth-provider": authProviderType,
@@ -94,7 +94,7 @@ function createAuthApolloLink(authProviderType, headersFromFetchProvider) {
94
94
  });
95
95
  }
96
96
  function createTokenLink(getToken) {
97
- return (0, import_context.setContext)(async () => {
97
+ return new import_context.SetContextLink(async () => {
98
98
  const token = await getToken();
99
99
  return { token };
100
100
  });
@@ -110,7 +110,7 @@ function createFinalLink({
110
110
  return userConfiguredLink;
111
111
  }
112
112
  }
113
- return import_core2.ApolloLink.from(defaultLinks.map((l) => l.link));
113
+ return import_client.ApolloLink.from(defaultLinks.map((l) => l.link));
114
114
  }
115
115
  // Annotate the CommonJS export names for ESM import in node:
116
116
  0 && (module.exports = {
@@ -1,16 +1,15 @@
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';
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?: HttpOptions;
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,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"}
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"}
@@ -23,10 +23,10 @@ __export(sseLink_exports, {
23
23
  isSubscription: () => isSubscription
24
24
  });
25
25
  module.exports = __toCommonJS(sseLink_exports);
26
- var import_core = require("@apollo/client/link/core/core.cjs");
27
- var import_utilities = require("@apollo/client/utilities/utilities.cjs");
26
+ var import_client = require("@apollo/client");
28
27
  var import_graphql = require("graphql");
29
28
  var import_graphql_sse = require("graphql-sse");
29
+ var import_rxjs = require("rxjs");
30
30
  const mapCredentialsHeader = (httpLinkCredentials) => {
31
31
  if (!httpLinkCredentials) {
32
32
  return void 0;
@@ -70,7 +70,7 @@ const isLiveQuery = (definition) => {
70
70
  }
71
71
  return !!definition.directives?.find((d) => d.name.value === "live");
72
72
  };
73
- class SSELink extends import_core.ApolloLink {
73
+ class SSELink extends import_client.ApolloLink {
74
74
  client;
75
75
  constructor(options) {
76
76
  super();
@@ -93,17 +93,14 @@ class SSELink extends import_core.ApolloLink {
93
93
  });
94
94
  }
95
95
  request(operation) {
96
- return new import_utilities.Observable((sink) => {
97
- let request;
98
- if (hasTrustedDocument(operation)) {
99
- delete operation.query;
100
- request = { ...operation };
101
- } else {
102
- request = {
103
- ...operation,
104
- query: (0, import_graphql.print)(operation.query)
105
- };
106
- }
96
+ return new import_rxjs.Observable((sink) => {
97
+ const { operationName, variables, extensions } = operation;
98
+ const request = hasTrustedDocument(operation) ? { operationName, variables, extensions } : {
99
+ operationName,
100
+ variables,
101
+ extensions,
102
+ query: (0, import_graphql.print)(operation.query)
103
+ };
107
104
  return this.client.subscribe(request, {
108
105
  next: sink.next.bind(sink),
109
106
  complete: sink.complete.bind(sink),
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import type { ApolloClientOptions, ApolloLink, HttpOptions, InMemoryCacheConfig, setLogVerbosity } from '@apollo/client';
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<ApolloClientOptions<unknown>, 'cache' | 'link'> & {
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?: HttpOptions;
27
+ httpLinkConfig?: HttpLink.Options;
28
28
  /**
29
29
  * Extend or overwrite `CedarApolloProvider`'s Apollo Link.
30
30
  *