@meshmakers/octo-services 3.4.890 → 3.4.910

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.
@@ -56,16 +56,37 @@ class OctoErrorLink extends ApolloLink {
56
56
  }
57
57
  showError(combinedGraphQLErrors) {
58
58
  const messageService = this.injector.get(MessageService);
59
- let title = 'GraphQL error';
60
- let details = '';
59
+ // Dedupe identical errors before rendering. A list query with one broken field produces one
60
+ // error PER ROW (observed on AB#4771: 13 rollup rows each yielded the same "Error trying to
61
+ // resolve field 'columns'" / INVALID_OPERATION), which used to flood the toast with the same
62
+ // message N times. Identical (message, code, OctoDetails) tuples collapse into one entry with
63
+ // an "(× N)" suffix; every raw error is still logged to the console individually.
64
+ const deduped = new Map();
61
65
  for (const error of combinedGraphQLErrors.errors) {
62
66
  console.error(error);
67
+ const key = JSON.stringify([
68
+ error.message,
69
+ error.extensions?.['code'] ?? null,
70
+ error.extensions?.['OctoDetails'] ?? null,
71
+ ]);
72
+ const entry = deduped.get(key);
73
+ if (entry) {
74
+ entry.count++;
75
+ }
76
+ else {
77
+ deduped.set(key, { error, count: 1 });
78
+ }
79
+ }
80
+ let title = 'GraphQL error';
81
+ let details = '';
82
+ for (const { error, count } of deduped.values()) {
83
+ const message = count > 1 ? `${error.message} (× ${count})` : `${error.message}`;
63
84
  if (title == 'GraphQL error') {
64
- title = `${error.message}`;
85
+ title = message;
65
86
  }
66
87
  else {
67
88
  details += `======================`;
68
- details += `${error.message}`;
89
+ details += message;
69
90
  }
70
91
  if (error.extensions) {
71
92
  // check for custom error properties, OctoDetails should be an array of MessageDetails