@cedarjs/web 7.0.0-canary.3258 → 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.
Files changed (71) hide show
  1. package/apollo/index.js +1 -0
  2. package/apollo/package.json +5 -0
  3. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts +3 -9
  4. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +1 -1
  5. package/dist/apollo/ApolloProviderWithFetchConfig.js +37 -60
  6. package/dist/apollo/CedarApolloProvider.d.ts +0 -1
  7. package/dist/apollo/CedarApolloProvider.d.ts.map +1 -1
  8. package/dist/apollo/CedarApolloProvider.js +6 -13
  9. package/dist/apollo/apolloLinkTypes.d.ts +4 -9
  10. package/dist/apollo/apolloLinkTypes.d.ts.map +1 -1
  11. package/dist/apollo/fragmentRegistry.d.ts +3 -3
  12. package/dist/apollo/fragmentRegistry.d.ts.map +1 -1
  13. package/dist/apollo/fragmentRegistry.js +8 -35
  14. package/dist/apollo/index.d.ts +0 -4
  15. package/dist/apollo/index.d.ts.map +1 -1
  16. package/dist/apollo/index.js +1 -3
  17. package/dist/apollo/links.d.ts +5 -6
  18. package/dist/apollo/links.d.ts.map +1 -1
  19. package/dist/apollo/links.js +9 -14
  20. package/dist/apollo/sseLink.d.ts +8 -5
  21. package/dist/apollo/sseLink.d.ts.map +1 -1
  22. package/dist/apollo/sseLink.js +12 -9
  23. package/dist/apollo/suspense.d.ts +3 -5
  24. package/dist/apollo/suspense.d.ts.map +1 -1
  25. package/dist/apollo/suspense.js +7 -35
  26. package/dist/apollo/useCache.d.ts +6 -4
  27. package/dist/apollo/useCache.d.ts.map +1 -1
  28. package/dist/apollo/useCache.js +1 -1
  29. package/dist/bundled/apollo-upload-client.d.ts +2 -2
  30. package/dist/bundled/apollo-upload-client.d.ts.map +1 -1
  31. package/dist/bundled/apollo-upload-client.js +1685 -1513
  32. package/dist/components/DevFatalErrorPage.d.ts +3 -3
  33. package/dist/components/DevFatalErrorPage.d.ts.map +1 -1
  34. package/dist/components/DevFatalErrorPage.js +49 -66
  35. package/dist/components/FatalErrorBoundary.d.ts +1 -1
  36. package/dist/components/cell/CellErrorBoundary.d.ts +3 -3
  37. package/dist/components/cell/CellErrorBoundary.d.ts.map +1 -1
  38. package/dist/components/cell/cellTypes.d.ts +18 -51
  39. package/dist/components/cell/cellTypes.d.ts.map +1 -1
  40. package/dist/components/cell/createCell.d.ts +1 -2
  41. package/dist/components/cell/createCell.d.ts.map +1 -1
  42. package/dist/components/cell/createCell.js +60 -65
  43. package/dist/components/cell/createFragmentCell.d.ts +1 -2
  44. package/dist/components/cell/createFragmentCell.d.ts.map +1 -1
  45. package/dist/components/cell/createFragmentCell.js +2 -4
  46. package/dist/components/cell/createServerCell.d.ts +2 -3
  47. package/dist/components/cell/createServerCell.d.ts.map +1 -1
  48. package/dist/components/cell/createServerCell.js +2 -4
  49. package/dist/components/cell/createSuspendingCell.d.ts +1 -2
  50. package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
  51. package/dist/components/cell/createSuspendingCell.js +34 -37
  52. package/dist/index.d.ts +2 -3
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +5 -2
  55. package/dist/server/middleware.d.ts +1 -1
  56. package/dist/server/middleware.d.ts.map +1 -1
  57. package/package.json +26 -20
  58. package/toast/index.js +1 -0
  59. package/toast/package.json +5 -0
  60. package/dist/apollo/ApolloClientFactoryContext.d.ts +0 -26
  61. package/dist/apollo/ApolloClientFactoryContext.d.ts.map +0 -1
  62. package/dist/apollo/ApolloClientFactoryContext.js +0 -5
  63. package/dist/apollo/parsedScalars.d.ts +0 -36
  64. package/dist/apollo/parsedScalars.d.ts.map +0 -1
  65. package/dist/apollo/parsedScalars.js +0 -75
  66. package/dist/apollo/typeOverrides.d.ts +0 -8
  67. package/dist/apollo/typeOverrides.d.ts.map +0 -1
  68. package/dist/apollo/typeOverrides.js +0 -0
  69. package/dist/apollo/useCreateApolloClient.d.ts +0 -11
  70. package/dist/apollo/useCreateApolloClient.d.ts.map +0 -1
  71. package/dist/apollo/useCreateApolloClient.js +0 -14
@@ -1,17 +1,17 @@
1
1
  import React from 'react';
2
- import type { GraphQLFormattedError } from 'graphql';
2
+ import type { GraphQLError } from 'graphql';
3
3
  type RequestDetails = {
4
4
  query: string;
5
5
  operationName: string;
6
6
  operationKind: string;
7
7
  variables: any;
8
8
  };
9
- interface EnhancedGqlError extends GraphQLFormattedError {
9
+ interface EnhancedGqlError extends GraphQLError {
10
10
  __RedwoodEnhancedError: RequestDetails;
11
11
  }
12
12
  type ErrorWithRequestMeta = Error & {
13
13
  mostRecentRequest?: RequestDetails;
14
- errors?: EnhancedGqlError[];
14
+ graphQLErrors?: EnhancedGqlError[];
15
15
  mostRecentResponse?: any;
16
16
  };
17
17
  export declare const DevFatalErrorPage: (props: {
@@ -1 +1 @@
1
- {"version":3,"file":"DevFatalErrorPage.d.ts","sourceRoot":"","sources":["../../src/components/DevFatalErrorPage.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAmBpD,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,GAAG,CAAA;CACf,CAAA;AAED,UAAU,gBAAiB,SAAQ,qBAAqB;IACtD,sBAAsB,EAAE,cAAc,CAAA;CACvC;AAID,KAAK,oBAAoB,GAAG,KAAK,GAAG;IAClC,iBAAiB,CAAC,EAAE,cAAc,CAAA;IAClC,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC3B,kBAAkB,CAAC,EAAE,GAAG,CAAA;CACzB,CAAA;AA+GD,eAAO,MAAM,iBAAiB,GAAI,OAAO;IAAE,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAAE,sBA4FxE,CAAA"}
1
+ {"version":3,"file":"DevFatalErrorPage.d.ts","sourceRoot":"","sources":["../../src/components/DevFatalErrorPage.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAmB3C,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,GAAG,CAAA;CACf,CAAA;AAED,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,sBAAsB,EAAE,cAAc,CAAA;CACvC;AAGD,KAAK,oBAAoB,GAAG,KAAK,GAAG;IAClC,iBAAiB,CAAC,EAAE,cAAc,CAAA;IAClC,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAClC,kBAAkB,CAAC,EAAE,GAAG,CAAA;CACzB,CAAA;AAiGD,eAAO,MAAM,iBAAiB,GAAI,OAAO;IAAE,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAAE,sBA4FxE,CAAA"}
@@ -10,90 +10,73 @@ if (/^[A-Z]:\\/.test(srcRoot)) {
10
10
  } else {
11
11
  appRoot = srcRoot.substring(1);
12
12
  }
13
- function formatMarkdownCode(value) {
14
- const fence = "`".repeat(longestBacktickRun(value) + 1);
15
- const padding = value.startsWith("`") || value.endsWith("`") ? " " : "";
16
- return `${fence}${padding}${value}${padding}${fence}`;
17
- }
18
- function formatMarkdownCodeBlock(value, language) {
19
- const fence = "`".repeat(Math.max(3, longestBacktickRun(value) + 1));
20
- return `${fence}${language}
21
- ${value}
22
- ${fence}`;
23
- }
24
- function longestBacktickRun(value) {
25
- return Array.from(value.matchAll(/`+/g)).reduce(
26
- (longest, [run]) => Math.max(longest, run.length),
27
- 0
28
- );
29
- }
30
- function formatErrorForClipboard(stack, typeName, msg, errorWithMeta) {
31
- const sections = [
32
- `## Error
33
-
34
- ${formatMarkdownCode(typeName)}: ${formatMarkdownCode(msg)}`
35
- ];
36
- const mostRecentRequest = errorWithMeta.mostRecentRequest || errorWithMeta.errors?.find((gqlErr) => gqlErr.__RedwoodEnhancedError)?.__RedwoodEnhancedError;
13
+ function formatErrorForClipboard(err, stack, typeName, msg, errorWithMeta) {
14
+ const lines = [];
15
+ lines.push("=".repeat(80));
16
+ lines.push("FATAL ERROR REPORT");
17
+ lines.push("=".repeat(80));
18
+ lines.push("");
19
+ lines.push(`ERROR TYPE: ${typeName}`);
20
+ lines.push(`ERROR MESSAGE: ${msg}`);
21
+ lines.push("");
22
+ const mostRecentRequest = errorWithMeta.mostRecentRequest || errorWithMeta.graphQLErrors?.find((gqlErr) => gqlErr.__RedwoodEnhancedError)?.__RedwoodEnhancedError;
37
23
  if (mostRecentRequest) {
38
- let variables;
24
+ lines.push("-".repeat(80));
25
+ lines.push("REQUEST CONTEXT");
26
+ lines.push("-".repeat(80));
27
+ lines.push(`Operation: ${mostRecentRequest.operationName}`);
28
+ lines.push(`Kind: ${mostRecentRequest.operationKind}`);
29
+ lines.push("");
30
+ lines.push("Variables:");
39
31
  try {
40
- variables = JSON.stringify(mostRecentRequest.variables, null, 2) ?? "undefined";
32
+ lines.push(JSON.stringify(mostRecentRequest.variables, null, 2));
41
33
  } catch {
42
- variables = "Unable to stringify variables";
34
+ lines.push("Unable to stringify variables");
43
35
  }
44
- sections.push(
45
- [
46
- "## Request",
47
- "",
48
- `${mostRecentRequest.operationKind} ${mostRecentRequest.operationName}`,
49
- "",
50
- "### Variables",
51
- "",
52
- formatMarkdownCodeBlock(variables, "json"),
53
- "",
54
- "### Query",
55
- "",
56
- formatMarkdownCodeBlock(mostRecentRequest.query, "graphql")
57
- ].join("\n")
58
- );
36
+ lines.push("");
37
+ lines.push("Query:");
38
+ lines.push(mostRecentRequest.query);
39
+ lines.push("");
59
40
  }
60
41
  if (errorWithMeta.mostRecentResponse) {
61
- let response;
42
+ lines.push("-".repeat(80));
43
+ lines.push("RESPONSE CONTEXT");
44
+ lines.push("-".repeat(80));
62
45
  try {
63
- response = JSON.stringify(errorWithMeta.mostRecentResponse, null, 2) ?? "undefined";
46
+ lines.push(JSON.stringify(errorWithMeta.mostRecentResponse, null, 2));
64
47
  } catch {
65
- response = "Unable to stringify response";
48
+ lines.push("Unable to stringify response");
66
49
  }
67
- sections.push(`## Response
68
-
69
- ${formatMarkdownCodeBlock(response, "json")}`);
50
+ lines.push("");
70
51
  }
71
- const stackEntries = stack.items.map((entry, i) => {
72
- const file = entry.fileShort || "[Unknown]";
52
+ lines.push("-".repeat(80));
53
+ lines.push("STACK TRACE");
54
+ lines.push("-".repeat(80));
55
+ stack.items.forEach((entry, i) => {
56
+ const fileShort = entry.fileShort || "[Unknown]";
73
57
  const callee = entry.callee || "[Anonymous]";
74
- const location = `${file}:${entry.line || "?"}:${entry.column || "?"}`;
75
- const lines = [`${i + 1}. \`${location}\` in \`${callee}\``];
58
+ const line = entry.line || "?";
59
+ const column = entry.column || "?";
60
+ lines.push(`[${i}] ${fileShort}:${line}:${column} in ${callee}`);
76
61
  const sourceFile = entry.sourceFile;
77
- if (sourceFile?.lines.length && entry.line && entry.line <= sourceFile.lines.length && !entry.thirdParty) {
78
- const lineIndex = entry.line - 1;
62
+ if (sourceFile?.lines && sourceFile.lines.length > 0) {
63
+ const lineIndex = (entry.line || 1) - 1;
79
64
  const window = 2;
80
65
  const start = Math.max(0, lineIndex - window);
81
66
  const end = Math.min(sourceFile.lines.length, lineIndex + window + 1);
82
- const sourceLines = [];
67
+ lines.push(" Source context:");
83
68
  for (let idx = start; idx < end; idx++) {
84
- const marker = idx === lineIndex ? ">" : " ";
85
- sourceLines.push(
86
- `${marker} ${(idx + 1).toString().padStart(4)} | ${sourceFile.lines[idx]}`
69
+ const marker = idx === lineIndex ? "> " : " ";
70
+ lines.push(
71
+ ` ${marker}${(idx + 1).toString().padStart(4)} | ${sourceFile.lines[idx]}`
87
72
  );
88
73
  }
89
- lines.push("", formatMarkdownCodeBlock(sourceLines.join("\n"), "text"));
74
+ lines.push("");
90
75
  }
91
- return lines.join("\n");
92
76
  });
93
- sections.push(`## Stack trace
94
-
95
- ${stackEntries.join("\n\n")}`);
96
- return sections.join("\n\n");
77
+ lines.push("");
78
+ lines.push("=".repeat(80));
79
+ return lines.join("\n");
97
80
  }
98
81
  const DevFatalErrorPage = (props) => {
99
82
  const [copyFeedback, setCopyFeedback] = useState("");
@@ -116,7 +99,7 @@ const DevFatalErrorPage = (props) => {
116
99
  const msg = String(err?.message);
117
100
  const FileRef = stack.items[0] ? /* @__PURE__ */ React.createElement("a", { href: toVSCodeURL(stack.items[0]) }, stack.items[0].fileName) : null;
118
101
  const handleCopyAll = async () => {
119
- const errorText = formatErrorForClipboard(stack, typeName, msg, err);
102
+ const errorText = formatErrorForClipboard(err, stack, typeName, msg, err);
120
103
  try {
121
104
  await navigator.clipboard.writeText(errorText);
122
105
  setCopyFeedback("\u2713 Copied to clipboard");
@@ -211,7 +194,7 @@ function ResponseRequest(props) {
211
194
  if (!props.error) {
212
195
  return null;
213
196
  }
214
- const mostRecentRequest = props.error.mostRecentRequest || props.error.errors?.find((gqlErr) => gqlErr.__RedwoodEnhancedError)?.__RedwoodEnhancedError;
197
+ const mostRecentRequest = props.error.mostRecentRequest || props.error.graphQLErrors?.find((gqlErr) => gqlErr.__RedwoodEnhancedError)?.__RedwoodEnhancedError;
215
198
  const mostRecentResponse = props.error.mostRecentResponse;
216
199
  return /* @__PURE__ */ React.createElement("div", { className: "request-response" }, mostRecentRequest ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h4", null, "Request: ", mostRecentRequest.operationName), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h5", null, "Variables:"), /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement("pre", null, JSON.stringify(mostRecentRequest.variables, null, " ")))), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h5", null, "Query:"), /* @__PURE__ */ React.createElement("code", null, /* @__PURE__ */ React.createElement(
217
200
  "pre",
@@ -18,7 +18,7 @@ declare class FatalErrorBoundary extends React.Component<PropsFatalErrorBoundary
18
18
  hasError: boolean;
19
19
  error: Error;
20
20
  };
21
- render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
21
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.PromiseLikeOfReactNode | React.JSX.Element | null | undefined;
22
22
  }
23
23
  export { FatalErrorBoundary };
24
24
  //# sourceMappingURL=FatalErrorBoundary.d.ts.map
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import type { useQuery } from '@apollo/client/react';
2
+ import type { QueryResult } from '@apollo/client';
3
3
  import type { CellFailureProps } from './cellTypes.js';
4
4
  export type FallbackProps = {
5
- error: useQuery.Result['error'];
5
+ error: QueryResult['error'];
6
6
  resetErrorBoundary: () => void;
7
7
  };
8
8
  export type CellErrorBoundaryProps = {
@@ -11,7 +11,7 @@ export type CellErrorBoundaryProps = {
11
11
  };
12
12
  interface ErrState {
13
13
  hasError: boolean;
14
- error?: useQuery.Result['error'];
14
+ error?: QueryResult['error'];
15
15
  }
16
16
  export declare class CellErrorBoundary extends React.Component<CellErrorBoundaryProps, ErrState> {
17
17
  constructor(props: CellErrorBoundaryProps);
@@ -1 +1 @@
1
- {"version":3,"file":"CellErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/cell/CellErrorBoundary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,OA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AAO,CAAA;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;CAC7B;AAED,qBAAa,iBAAkB,SAAQ,KAAK,CAAC,SAAS,CACpD,sBAAsB,EACtB,QAAQ,CACT;gBACa,KAAK,EAAE,sBAAsB;IAKzC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;;;IAI5C,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;IAQ1D,MAAM;CAgBP"}
@@ -1,6 +1,5 @@
1
- import type { ComponentProps, JSX, JSXElementConstructor } from 'react';
2
- import type { ApolloClient, NetworkStatus, OperationVariables, TypedDocumentNode } from '@apollo/client';
3
- import type { QueryRef, SkipToken, useBackgroundQuery, useQuery } from '@apollo/client/react';
1
+ import type { ComponentProps, JSXElementConstructor } from 'react';
2
+ import type { ApolloClient, NetworkStatus, OperationVariables, QueryRef, QueryResult, UseBackgroundQueryResult } from '@apollo/client';
4
3
  import type { DocumentNode } from 'graphql';
5
4
  import type { A, L, O, U } from 'ts-toolbelt';
6
5
  /**
@@ -22,7 +21,7 @@ type CellPropsVariables<Cell, GQLVariables> = Cell extends {
22
21
  * Cell component props which is the combination of query variables and Success props.
23
22
  */
24
23
  export type CellProps<CellSuccess extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>, GQLResult, CellType, GQLVariables> = A.Compute<Omit<ComponentProps<CellSuccess>, keyof CellPropsVariables<CellType, GQLVariables> | keyof (GQLVariables extends Record<string, never> ? unknown : GQLVariables) | keyof GQLResult | 'updating' | 'queryResult'> & CellPropsVariables<CellType, GQLVariables>>;
25
- type InputVarProps<T> = unknown extends T ? unknown : T extends {
24
+ type InputVarProps<T> = T extends {
26
25
  [key: string]: never;
27
26
  } ? unknown : T;
28
27
  export type CellLoadingProps<TVariables extends OperationVariables = any> = {
@@ -30,7 +29,7 @@ export type CellLoadingProps<TVariables extends OperationVariables = any> = {
30
29
  } & InputVarProps<TVariables>;
31
30
  export type CellFailureProps<TVariables extends OperationVariables = any> = {
32
31
  queryResult?: NonSuspenseCellQueryResult<TVariables, any> | SuspenseCellQueryResult;
33
- error?: useQuery.Result['error'] | Error;
32
+ error?: QueryResult['error'] | Error;
34
33
  /**
35
34
  * @see {@link https://www.apollographql.com/docs/apollo-server/data/errors/#error-codes}
36
35
  */
@@ -76,50 +75,17 @@ export type CellSuccessProps<TData = any, TVariables extends OperationVariables
76
75
  export type DataObject = {
77
76
  [key: string]: unknown;
78
77
  };
79
- /**
80
- * What `beforeQuery` returns is handed straight to the GraphQL client's query
81
- * hook, so any of that hook's options can be set here.
82
- */
83
- export type CellBeforeQueryOptions<CellVariables> = {
84
- variables: CellVariables;
85
- } & Omit<useQuery.Options<DataObject, OperationVariables>, 'variables'>;
86
- /**
87
- * `beforeQuery` can return `skipToken` instead of an options object to keep the
88
- * query from being executed at all. A skipped Cell renders nothing -- none of
89
- * `Loading`, `Empty`, `Failure` or `Success` are rendered.
90
- *
91
- * @see {@link https://www.apollographql.com/docs/react/api/react/hooks#skiptoken}
92
- *
93
- * @example
94
- * ```ts
95
- * import { skipToken } from '@apollo/client/react'
96
- *
97
- * export const beforeQuery = ({ id }) => {
98
- * const otherId = useStore((state) => state.getOther(id))
99
- *
100
- * return otherId ? { variables: { id, otherId } } : skipToken
101
- * }
102
- * ```
103
- */
104
- export type CellBeforeQueryResult<CellVariables> = CellBeforeQueryOptions<CellVariables> | SkipToken;
105
78
  /**
106
79
  * The main interface.
107
- *
108
- * @param GQLResult - The shape of the data returned by `QUERY` (or, for
109
- * fragment Cells, the shape of the fragment's data). This is what
110
- * `Success`/`Empty` receive their data as. Defaults to `any` so Cells that
111
- * don't -- or can't -- type their `QUERY` with `TypedDocumentNode` (e.g. in
112
- * tests, or Cells built from a plain string) keep the pre-existing loose
113
- * behavior instead of erroring.
114
80
  */
115
- export interface CreateCellProps<CellProps, CellVariables extends OperationVariables = OperationVariables, GQLResult = any> {
81
+ export interface CreateCellProps<CellProps, CellVariables> {
116
82
  /**
117
83
  * The GraphQL syntax tree to execute or function to call that returns it.
118
84
  * If `QUERY` is a function, it's called with the result of `beforeQuery`.
119
85
  *
120
86
  * Either `QUERY` or `FRAGMENT` must be provided.
121
87
  */
122
- QUERY?: TypedDocumentNode<GQLResult, CellVariables> | DocumentNode | ((variables: Record<string, unknown>) => DocumentNode);
88
+ QUERY?: DocumentNode | ((variables: Record<string, unknown>) => DocumentNode);
123
89
  /**
124
90
  * A GraphQL fragment that declares this Cell's data requirements. Fragment
125
91
  * Cells don't fire their own query. Instead a parent Cell spreads the
@@ -133,11 +99,12 @@ export interface CreateCellProps<CellProps, CellVariables extends OperationVaria
133
99
  FRAGMENT?: DocumentNode;
134
100
  /**
135
101
  * Parse `props` into query variables. Most of the time `props` are appropriate variables as is.
136
- *
137
- * Any other option the GraphQL client's query hook accepts can be returned
138
- * here as well. Return `skipToken` to not execute the query at all.
139
102
  */
140
- beforeQuery?: ((props: CellProps) => CellBeforeQueryResult<CellVariables>) | (() => CellBeforeQueryResult<CellVariables>);
103
+ beforeQuery?: ((props: CellProps) => {
104
+ variables: CellVariables;
105
+ }) | (() => {
106
+ variables: CellVariables;
107
+ });
141
108
  /**
142
109
  * Sanitize the data returned from the query.
143
110
  */
@@ -167,19 +134,19 @@ export interface CreateCellProps<CellProps, CellVariables extends OperationVaria
167
134
  /**
168
135
  * If the query's in flight and there's no stale data, render this.
169
136
  */
170
- Loading?: React.FC<CellLoadingProps<CellVariables> & Partial<CellProps>>;
137
+ Loading?: React.FC<CellLoadingProps & Partial<CellProps>>;
171
138
  /**
172
139
  * If something went wrong, render this.
173
140
  */
174
- Failure?: React.FC<CellFailureProps<CellVariables> & Partial<CellProps>>;
141
+ Failure?: React.FC<CellFailureProps & Partial<CellProps>>;
175
142
  /**
176
143
  * If no data was returned, render this.
177
144
  */
178
- Empty?: React.FC<CellSuccessProps<GQLResult, CellVariables> & Partial<CellProps>>;
145
+ Empty?: React.FC<CellSuccessProps & Partial<CellProps>>;
179
146
  /**
180
147
  * If data was returned, render this.
181
148
  */
182
- Success: React.FC<CellSuccessProps<GQLResult, CellVariables> & Partial<CellProps>>;
149
+ Success: React.FC<CellSuccessProps & Partial<CellProps>>;
183
150
  /**
184
151
  * What to call the Cell. Defaults to the filename.
185
152
  */
@@ -190,9 +157,9 @@ export type SuspendingSuccessProps = React.PropsWithChildren<Record<string, unkn
190
157
  suspenseQueryResult: SuspenseCellQueryResult<DataObject, any>;
191
158
  userProps: Record<string, any>;
192
159
  };
193
- export type NonSuspenseCellQueryResult<TVariables extends OperationVariables = any, TData = any> = Partial<Omit<useQuery.Result<TData, TVariables>, 'loading' | 'error' | 'data'>>;
194
- export interface SuspenseCellQueryResult<_TData = any, _TVariables extends OperationVariables = any> extends useBackgroundQuery.Result<DataObject> {
195
- client: ApolloClient;
160
+ export type NonSuspenseCellQueryResult<TVariables extends OperationVariables = any, TData = any> = Partial<Omit<QueryResult<TData, TVariables>, 'loading' | 'error' | 'data'>>;
161
+ export interface SuspenseCellQueryResult<_TData = any, _TVariables extends OperationVariables = any> extends UseBackgroundQueryResult {
162
+ client: ApolloClient<any>;
196
163
  networkStatus?: NetworkStatus;
197
164
  called: boolean;
198
165
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cellTypes.d.ts","sourceRoot":"","sources":["../../../src/components/cell/cellTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAA;AAEvE,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,QAAQ,EACT,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EA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U,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC,CAAA;AAI/E,MAAM,WAAW,uBAAuB,CACtC,MAAM,GAAG,GAAG,EACZ,WAAW,SAAS,kBAAkB,GAAG,GAAG,CAC5C,SAAQ,wBAAwB;IAChC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;IAEzB,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,MAAM,EAAE,OAAO,CAAA;CAChB"}
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import type { OperationVariables } from '@apollo/client';
3
2
  import type { CreateCellProps } from './cellTypes.js';
4
- export declare function createCell<CellProps extends Record<string, unknown>, CellVariables extends OperationVariables = OperationVariables, GQLResult = any>(createCellProps: CreateCellProps<CellProps, CellVariables, GQLResult>): React.FC<CellProps>;
3
+ export declare function createCell<CellProps extends Record<string, unknown>, CellVariables extends Record<string, unknown>>(createCellProps: CreateCellProps<CellProps, CellVariables>): React.FC<CellProps>;
5
4
  //# sourceMappingURL=createCell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAQxD,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,gBAAgB,CAAA;AAKjE,wBAAgB,UAAU,CACxB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,EAEf,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,GACpE,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAoCrB"}
1
+ {"version":3,"file":"createCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAKrD,wBAAgB,UAAU,CACxB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE7C,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,GACzD,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAiCrB"}
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { CombinedGraphQLErrors } from "@apollo/client";
3
- import { useQuery } from "@apollo/client/react";
2
+ import { useQuery } from "@apollo/client/react/hooks/hooks.cjs";
4
3
  import { fragmentRegistry } from "../../apollo/fragmentRegistry.js";
5
4
  import { getOperationName } from "../../graphql.js";
6
5
  import { useCellCacheContext } from "./CellCacheContext.js";
@@ -16,9 +15,7 @@ function createCell(createCellProps) {
16
15
  }
17
16
  if (RWJS_ENV.RWJS_EXP_STREAMING_SSR) {
18
17
  const suspendingCellProps = createCellProps;
19
- return createSuspendingCell(
20
- suspendingCellProps
21
- );
18
+ return createSuspendingCell(suspendingCellProps);
22
19
  }
23
20
  return createNonSuspendingCell(createCellProps);
24
21
  }
@@ -53,9 +50,7 @@ function createNonSuspendingCell({
53
50
  function NamedCell(props) {
54
51
  const { children: _, ...variables } = props;
55
52
  const options = beforeQuery(variables);
56
- const queryOptions = typeof options === "symbol" ? void 0 : options;
57
- const skipped = !queryOptions || queryOptions.skip === true;
58
- const query = typeof cellQuery === "function" ? cellQuery(queryOptions ?? {}) : cellQuery;
53
+ const query = typeof cellQuery === "function" ? cellQuery(options) : cellQuery;
59
54
  let {
60
55
  // eslint-disable-next-line prefer-const
61
56
  error,
@@ -65,77 +60,77 @@ function createNonSuspendingCell({
65
60
  } = useQuery(query, options);
66
61
  if (globalThis.__REDWOOD__PRERENDERING) {
67
62
  const { queryCache } = useCellCacheContext();
68
- if (!skipped) {
69
- const operationName = getOperationName(query);
70
- const transformedQuery = fragmentRegistry.transform(query);
71
- let cacheKey;
72
- if (operationName) {
73
- cacheKey = operationName + "_" + JSON.stringify(variables);
63
+ const operationName = getOperationName(query);
64
+ const transformedQuery = fragmentRegistry.transform(query);
65
+ let cacheKey;
66
+ if (operationName) {
67
+ cacheKey = operationName + "_" + JSON.stringify(variables);
68
+ } else {
69
+ const cellName = displayName === "Cell" ? "the cell" : displayName;
70
+ throw new Error(
71
+ `The gql query in ${cellName} is missing an operation name. Something like FindBlogPostQuery in \`query FindBlogPostQuery($id: Int!)\``
72
+ );
73
+ }
74
+ const queryInfo = queryCache[cacheKey];
75
+ if (queryInfo?.renderLoading) {
76
+ loading = true;
77
+ } else {
78
+ if (queryInfo?.hasProcessed) {
79
+ loading = false;
80
+ data = queryInfo.data;
81
+ queryResult = { variables };
74
82
  } else {
75
- const cellName = displayName === "Cell" ? "the cell" : displayName;
76
- throw new Error(
77
- `The gql query in ${cellName} is missing an operation name. Something like FindBlogPostQuery in \`query FindBlogPostQuery($id: Int!)\``
78
- );
79
- }
80
- const queryInfo = queryCache[cacheKey];
81
- if (queryInfo?.renderLoading) {
82
- loading = true;
83
- } else {
84
- if (queryInfo?.hasProcessed) {
85
- loading = false;
86
- data = queryInfo.data;
87
- queryResult = { variables };
88
- } else {
89
- queryCache[cacheKey] ||= {
90
- query: transformedQuery,
91
- variables: queryOptions.variables,
92
- hasProcessed: false
93
- };
94
- }
83
+ queryCache[cacheKey] ||= {
84
+ query: transformedQuery,
85
+ variables: options.variables,
86
+ hasProcessed: false
87
+ };
95
88
  }
96
89
  }
97
90
  }
98
- if (skipped) {
99
- return null;
100
- }
101
91
  if (error) {
102
92
  if (Failure) {
103
- const failureProps = {
104
- error,
105
- errorCode: (
106
- // Use the ad-hoc QueryResultWithErrorCode type to access the errorCode
107
- queryResult.errorCode ?? (CombinedGraphQLErrors.is(error) ? error.errors[0]?.extensions?.["code"] : void 0)
108
- ),
109
- ...props,
110
- updating: loading,
111
- queryResult
112
- };
113
- return /* @__PURE__ */ React.createElement(Failure, { ...failureProps });
93
+ return /* @__PURE__ */ React.createElement(
94
+ Failure,
95
+ {
96
+ error,
97
+ errorCode: (
98
+ // Use the ad-hoc QueryResultWithErrorCode type to access the errorCode
99
+ queryResult.errorCode ?? error.graphQLErrors?.[0]?.extensions?.["code"]
100
+ ),
101
+ ...props,
102
+ updating: loading,
103
+ queryResult
104
+ }
105
+ );
114
106
  } else {
115
- throw error instanceof Error ? error : new Error(error.message);
107
+ throw error;
116
108
  }
117
109
  } else if (data) {
118
110
  const afterQueryData = afterQuery(data);
119
111
  if (isEmpty(data, { isDataEmpty }) && Empty) {
120
- const emptyProps = {
121
- ...props,
122
- ...afterQueryData,
123
- updating: loading,
124
- queryResult
125
- };
126
- return /* @__PURE__ */ React.createElement(Empty, { ...emptyProps });
112
+ return /* @__PURE__ */ React.createElement(
113
+ Empty,
114
+ {
115
+ ...props,
116
+ ...afterQueryData,
117
+ updating: loading,
118
+ queryResult
119
+ }
120
+ );
127
121
  } else {
128
- const successProps = {
129
- ...props,
130
- ...afterQueryData,
131
- updating: loading,
132
- queryResult
133
- };
134
- return /* @__PURE__ */ React.createElement(Success, { ...successProps });
122
+ return /* @__PURE__ */ React.createElement(
123
+ Success,
124
+ {
125
+ ...props,
126
+ ...afterQueryData,
127
+ updating: loading,
128
+ queryResult
129
+ }
130
+ );
135
131
  }
136
132
  } else if (loading) {
137
- const loadingProps = { ...props, queryResult };
138
- return /* @__PURE__ */ React.createElement(Loading, { ...loadingProps });
133
+ return /* @__PURE__ */ React.createElement(Loading, { ...props, queryResult });
139
134
  } else {
140
135
  console.warn(
141
136
  `If you're using Apollo Client, check for its debug logs here in the console, which may help explain the error.`
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import type { OperationVariables } from '@apollo/client';
3
2
  import type { CreateCellProps } from './cellTypes.js';
4
3
  /**
5
4
  * Creates a Cell out of a GraphQL fragment and components that render its
@@ -16,5 +15,5 @@ import type { CreateCellProps } from './cellTypes.js';
16
15
  * mutations update the underlying entity. If the cache read is incomplete,
17
16
  * the passed-in object itself is used as the data snapshot.
18
17
  */
19
- export declare function createFragmentCell<CellProps extends Record<string, unknown>, CellVariables extends OperationVariables = OperationVariables, GQLResult = any>({ FRAGMENT, afterQuery, isEmpty, Empty, Success, displayName, }: CreateCellProps<CellProps, CellVariables, GQLResult>): React.FC<CellProps>;
18
+ export declare function createFragmentCell<CellProps extends Record<string, unknown>, CellVariables extends Record<string, unknown>>({ FRAGMENT, afterQuery, isEmpty, Empty, Success, displayName, }: CreateCellProps<CellProps, CellVariables>): React.FC<CellProps>;
20
19
  //# sourceMappingURL=createFragmentCell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createFragmentCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createFragmentCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAMxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAqDrD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,EACf,EACA,QAAQ,EACR,UAA2B,EAC3B,OAAqB,EACrB,KAAK,EACL,OAAO,EACP,WAAoB,GACrB,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAiF5E"}
1
+ {"version":3,"file":"createFragmentCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createFragmentCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAqDrD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7C,EACA,QAAQ,EACR,UAA2B,EAC3B,OAAqB,EACrB,KAAK,EACL,OAAO,EACP,WAAoB,GACrB,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAkEjE"}
@@ -58,12 +58,10 @@ function createFragmentCell({
58
58
  }
59
59
  const data = fragmentResult.complete ? fragmentResult.data : dataRef ?? null;
60
60
  const afterQueryData = afterQuery({ [propName]: data });
61
- const restProps = rest;
62
- const successProps = { ...restProps, ...afterQueryData };
63
61
  if (isEmpty({ [propName]: data }, { isDataEmpty }) && Empty) {
64
- return /* @__PURE__ */ React.createElement(Empty, { ...successProps });
62
+ return /* @__PURE__ */ React.createElement(Empty, { ...rest, ...afterQueryData });
65
63
  }
66
- return /* @__PURE__ */ React.createElement(Success, { ...successProps });
64
+ return /* @__PURE__ */ React.createElement(Success, { ...rest, ...afterQueryData });
67
65
  }
68
66
  NamedCell.displayName = displayName;
69
67
  return (props) => {
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import type { OperationVariables } from '@apollo/client';
3
2
  import type { CreateCellProps } from './cellTypes.js';
4
- type CreateServerCellProps<CellProps, CellVariables extends OperationVariables = OperationVariables, GQLResult = any> = Omit<CreateCellProps<CellProps, CellVariables, GQLResult>, 'QUERY' | 'Failure'> & {
3
+ type CreateServerCellProps<CellProps, CellVariables> = Omit<CreateCellProps<CellProps, CellVariables>, 'QUERY' | 'Failure'> & {
5
4
  data: (variables?: AnyObj) => any;
6
5
  Failure?: React.ComponentType<{
7
6
  error: unknown;
@@ -11,6 +10,6 @@ type CreateServerCellProps<CellProps, CellVariables extends OperationVariables =
11
10
  }>;
12
11
  };
13
12
  type AnyObj = Record<string, unknown>;
14
- export declare function createServerCell<CellProps extends AnyObj, CellVariables extends OperationVariables = OperationVariables, GQLResult = any>(createCellProps: CreateServerCellProps<CellProps, CellVariables, GQLResult>): React.FC<CellProps>;
13
+ export declare function createServerCell<CellProps extends AnyObj, CellVariables extends AnyObj>(createCellProps: CreateServerCellProps<CellProps, CellVariables>): React.FC<CellProps>;
15
14
  export {};
16
15
  //# sourceMappingURL=createServerCell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createServerCell.d.ts","sourceRoot":"","sources":["../../../src/components/cell/createServerCell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAMxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIrD,KAAK,qBAAqB,CACxB,SAAS,EACT,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,IACb,IAAI,CACN,eAAe,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,CAAC,EACpD,OAAO,GAAG,SAAS,CACpB,GAAG;IACF,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,GAAG,CAAA;IACjC,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAC5B,KAAK,EAAE,OAAO,CAAA;QACd,WAAW,EAAE;YAAE,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAA;SAAE,CAAA;KAC3D,CAAC,CAAA;CACH,CAAA;AAED,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAErC,wBAAgB,gBAAgB,CAC9B,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,kBAAkB,GAAG,kBAAkB,EAC7D,SAAS,GAAG,GAAG,EAEf,eAAe,EAAE,qBAAq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