@m1212e/rumble 0.16.21 → 0.16.22

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/out/index.cjs CHANGED
@@ -218,7 +218,7 @@ function mapNullFieldsToUndefined(obj) {
218
218
 
219
219
  //#endregion
220
220
  //#region package.json
221
- var version = "0.16.21";
221
+ var version = "0.16.22";
222
222
 
223
223
  //#endregion
224
224
  //#region lib/helpers/mergeFilters.ts
@@ -1640,13 +1640,23 @@ export const db = drizzle(
1640
1640
  return (0, graphql_yoga.createYoga)({
1641
1641
  ...args,
1642
1642
  graphiql: enableApiDocs,
1643
+ schema: builtSchema(),
1644
+ context,
1643
1645
  plugins: [
1644
1646
  ...args?.plugins ?? [],
1645
1647
  ...enableApiDocs ? [] : [(0, _graphql_yoga_plugin_disable_introspection.useDisableIntrospection)(), (0, _escape_tech_graphql_armor.EnvelopArmorPlugin)()],
1646
1648
  rumbleInput.otel?.enabled ? { onExecute: ({ setExecuteFn, executeFn }) => {
1647
- setExecuteFn((options) => rumbleInput.otel.tracer.startActiveSpan(_pothos_tracing_opentelemetry.SpanNames.EXECUTE, { attributes: { [_pothos_tracing_opentelemetry.AttributeNames.OPERATION_NAME]: options.operationName ?? "anonymous" } }, async (span) => {
1649
+ setExecuteFn((options) => rumbleInput.otel.tracer.startActiveSpan(_pothos_tracing_opentelemetry.SpanNames.EXECUTE, { attributes: {
1650
+ [_pothos_tracing_opentelemetry.AttributeNames.OPERATION_NAME]: options.operationName ?? "anonymous",
1651
+ [_pothos_tracing_opentelemetry.AttributeNames.SOURCE]: options.document
1652
+ } }, async (span) => {
1648
1653
  try {
1649
- return await executeFn(options);
1654
+ const result = await executeFn(options);
1655
+ if (result && "errors" in result && result.errors?.length) {
1656
+ for (const error of result.errors) span.recordException(error);
1657
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
1658
+ }
1659
+ return result;
1650
1660
  } catch (error) {
1651
1661
  if (error instanceof Error) span.recordException(error);
1652
1662
  span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
@@ -1656,17 +1666,30 @@ export const db = drizzle(
1656
1666
  }
1657
1667
  }));
1658
1668
  } } : false
1659
- ].filter(Boolean),
1660
- schema: builtSchema(),
1661
- context
1669
+ ].filter(Boolean)
1662
1670
  });
1663
1671
  };
1664
1672
  const createSofa = (args) => {
1665
1673
  if (args.openAPI) (0, es_toolkit.merge)(args.openAPI, sofaOpenAPIWebhookDocs);
1674
+ if (args.errorHandler) {
1675
+ const originalHandler = args.errorHandler;
1676
+ args.errorHandler = (errors) => {
1677
+ const span = _opentelemetry_api.trace.getActiveSpan();
1678
+ for (const error of errors) span?.recordException(error);
1679
+ span?.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
1680
+ return originalHandler(errors);
1681
+ };
1682
+ }
1666
1683
  return (0, sofa_api.useSofa)({
1667
1684
  ...args,
1668
1685
  schema: builtSchema(),
1669
- context
1686
+ context,
1687
+ errorHandler(errors) {
1688
+ const span = _opentelemetry_api.trace.getActiveSpan();
1689
+ for (const error of errors) span?.recordException(error);
1690
+ span?.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
1691
+ return new Response(errors[0].message, { status: 500 });
1692
+ }
1670
1693
  });
1671
1694
  };
1672
1695
  return {