@nestjs/apollo 11.0.0 → 11.0.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"apollo-base.driver.d.ts","sourceRoot":"","sources":["../../lib/drivers/apollo-base.driver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAShE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AASnD,8BAAsB,gBAAgB,CACpC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,kBAAkB,CAClD,SAAQ,qBAAqB,CAAC,CAAC,CAAC;IAChC,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IAElD,IAAI,QAAQ,IAAI,YAAY,CAAC,WAAW,CAAC,CAExC;IAEY,KAAK,CAAC,aAAa,EAAE,CAAC;IAa5B,IAAI;IAIE,mBAAmB,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IA6CjD,sBAAsB,CAC3B,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,CACR,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,GAAG,EACd,OAAO,EAAE,GAAG,KACT,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC/B,sBAAsB,EAAE,QAAQ,qHAI7B,GAAG;cAMQ,eAAe,CAC7B,OAAO,EAAE,CAAC,EACV,EAAE,YAAY,EAAE,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;KAAO;cAkCtC,eAAe,CAC7B,OAAO,EAAE,CAAC,EACV,EAAE,YAAY,EAAE,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;KAAO;IAuCtD,OAAO,CAAC,iBAAiB;IAi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C,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,iBAAiB;CAgB1B"}
@@ -130,9 +130,9 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
130
130
  if (options.formatError) {
131
131
  const origFormatError = options.formatError;
132
132
  const transformHttpErrorFn = this.createTransformHttpErrorFn();
133
- options.formatError = (err) => {
134
- err = transformHttpErrorFn(err);
135
- return origFormatError(err);
133
+ options.formatError = (formattedError, err) => {
134
+ err = transformHttpErrorFn(formattedError, err);
135
+ return origFormatError(formattedError, err);
136
136
  };
137
137
  }
138
138
  else {
@@ -141,32 +141,38 @@ class ApolloBaseDriver extends graphql_1.AbstractGraphQLDriver {
141
141
  }
142
142
  }
143
143
  createTransformHttpErrorFn() {
144
- return (originalError) => {
145
- var _a, _b;
146
- const exceptionRef = (_a = originalError === null || originalError === void 0 ? void 0 : originalError.extensions) === null || _a === void 0 ? void 0 : _a.exception;
147
- const isHttpException = ((_b = exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.response) === null || _b === void 0 ? void 0 : _b.statusCode) && (exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.status);
144
+ return (formattedError, originalError) => {
145
+ var _a;
146
+ const exceptionRef = (0, errors_1.unwrapResolverError)(originalError);
147
+ const isHttpException = ((_a = exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.response) === null || _a === void 0 ? void 0 : _a.statusCode) && (exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.status);
148
148
  if (!isHttpException) {
149
- return originalError;
149
+ return formattedError;
150
150
  }
151
151
  let error;
152
152
  const httpStatus = exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.status;
153
153
  if (httpStatus in apolloPredefinedExceptions) {
154
154
  error = new graphql_2.GraphQLError(exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.message, {
155
+ path: formattedError.path,
155
156
  extensions: {
157
+ ...formattedError.extensions,
156
158
  code: apolloPredefinedExceptions[httpStatus],
157
159
  },
158
160
  });
159
161
  }
160
162
  else {
161
163
  error = new graphql_2.GraphQLError(exceptionRef.message, {
164
+ path: formattedError.path,
162
165
  extensions: {
166
+ ...formattedError.extensions,
163
167
  code: errors_1.ApolloServerErrorCode.INTERNAL_SERVER_ERROR,
164
168
  status: httpStatus,
165
169
  },
166
170
  });
167
171
  }
168
- error.stack = exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.stacktrace;
169
- error.extensions['response'] = exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.response;
172
+ if (exceptionRef === null || exceptionRef === void 0 ? void 0 : exceptionRef.response) {
173
+ error.extensions['originalError'] = exceptionRef.response;
174
+ }
175
+ error.locations = formattedError.locations;
170
176
  return error;
171
177
  };
172
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/apollo",
3
- "version": "11.0.0",
3
+ "version": "11.0.2",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
5
5
  "author": "Kamil Mysliwiec",
6
6
  "license": "MIT",
@@ -60,5 +60,5 @@
60
60
  "optional": true
61
61
  }
62
62
  },
63
- "gitHead": "7b017103ba66ebe310a9d7adb56c89e92a836494"
63
+ "gitHead": "39f77a8d636c48df9927d40bfc510134d0aa2b33"
64
64
  }