@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.mjs CHANGED
@@ -185,7 +185,7 @@ function mapNullFieldsToUndefined(obj) {
185
185
 
186
186
  //#endregion
187
187
  //#region package.json
188
- var version = "0.16.21";
188
+ var version = "0.16.22";
189
189
 
190
190
  //#endregion
191
191
  //#region lib/helpers/mergeFilters.ts
@@ -1607,13 +1607,23 @@ export const db = drizzle(
1607
1607
  return createYoga({
1608
1608
  ...args,
1609
1609
  graphiql: enableApiDocs,
1610
+ schema: builtSchema(),
1611
+ context,
1610
1612
  plugins: [
1611
1613
  ...args?.plugins ?? [],
1612
1614
  ...enableApiDocs ? [] : [useDisableIntrospection(), EnvelopArmorPlugin()],
1613
1615
  rumbleInput.otel?.enabled ? { onExecute: ({ setExecuteFn, executeFn }) => {
1614
- setExecuteFn((options) => rumbleInput.otel.tracer.startActiveSpan(SpanNames.EXECUTE, { attributes: { [AttributeNames.OPERATION_NAME]: options.operationName ?? "anonymous" } }, async (span) => {
1616
+ setExecuteFn((options) => rumbleInput.otel.tracer.startActiveSpan(SpanNames.EXECUTE, { attributes: {
1617
+ [AttributeNames.OPERATION_NAME]: options.operationName ?? "anonymous",
1618
+ [AttributeNames.SOURCE]: options.document
1619
+ } }, async (span) => {
1615
1620
  try {
1616
- return await executeFn(options);
1621
+ const result = await executeFn(options);
1622
+ if (result && "errors" in result && result.errors?.length) {
1623
+ for (const error of result.errors) span.recordException(error);
1624
+ span.setStatus({ code: SpanStatusCode.ERROR });
1625
+ }
1626
+ return result;
1617
1627
  } catch (error) {
1618
1628
  if (error instanceof Error) span.recordException(error);
1619
1629
  span.setStatus({ code: SpanStatusCode.ERROR });
@@ -1623,17 +1633,30 @@ export const db = drizzle(
1623
1633
  }
1624
1634
  }));
1625
1635
  } } : false
1626
- ].filter(Boolean),
1627
- schema: builtSchema(),
1628
- context
1636
+ ].filter(Boolean)
1629
1637
  });
1630
1638
  };
1631
1639
  const createSofa = (args) => {
1632
1640
  if (args.openAPI) merge(args.openAPI, sofaOpenAPIWebhookDocs);
1641
+ if (args.errorHandler) {
1642
+ const originalHandler = args.errorHandler;
1643
+ args.errorHandler = (errors) => {
1644
+ const span = trace.getActiveSpan();
1645
+ for (const error of errors) span?.recordException(error);
1646
+ span?.setStatus({ code: SpanStatusCode.ERROR });
1647
+ return originalHandler(errors);
1648
+ };
1649
+ }
1633
1650
  return useSofa({
1634
1651
  ...args,
1635
1652
  schema: builtSchema(),
1636
- context
1653
+ context,
1654
+ errorHandler(errors) {
1655
+ const span = trace.getActiveSpan();
1656
+ for (const error of errors) span?.recordException(error);
1657
+ span?.setStatus({ code: SpanStatusCode.ERROR });
1658
+ return new Response(errors[0].message, { status: 500 });
1659
+ }
1637
1660
  });
1638
1661
  };
1639
1662
  return {