@m1212e/rumble 0.12.8 → 0.12.10

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
@@ -499,65 +499,8 @@ const assertFirstEntryExists = (value) => {
499
499
 
500
500
  //#endregion
501
501
  //#region lib/helpers/mapNullFieldsToUndefined.ts
502
- /**
503
- * Helper to map null fields to undefined
504
- * @param obj The object to map
505
- * @returns The mapped object with all fields of 'null' transformed to 'undefined'
506
- *
507
- * This becomes useful for update mutations where you do not want to pass null (unset value in db)
508
- * but undefined (do not touch value in db) in case of a value not beeing set in the args of said mutation
509
- * @example
510
- * ```ts
511
- * updateUser: t.drizzleField({
512
- type: User,
513
- args: {
514
- id: t.arg.string({ required: true }),
515
- email: t.arg.string(),
516
- lastName: t.arg.string(),
517
- firstName: t.arg.string(),
518
- },
519
- resolve: async (query, root, args, ctx, info) => {
520
- const mappedArgs = mapNullFieldsToUndefined(args);
521
- const user = await db.transaction(async (tx) => {
522
- const user = await tx
523
- .update(schema.user)
524
- .set({
525
-
526
- // email: args.email ?? undefined,
527
- // lastName: args.lastName ?? undefined,
528
- // firstName: args.firstName ?? undefined,
529
-
530
- // becomes this
531
-
532
- email: mappedArgs.email,
533
- lastName: mappedArgs.lastName,
534
- firstName: mappedArgs.firstName,
535
- })
536
- .returning()
537
- .then(assertFirstEntryExists);
538
- return user;
539
- });
540
-
541
- pubsub.updated(user.id);
542
-
543
- return db.query.user
544
- .findFirst(
545
- query(
546
- ctx.abilities.user.filter('read').merge(
547
- {
548
- where: { id: user.id },
549
- }
550
- 1).query.single,
551
- ),
552
- )
553
- .then(assertFindFirstExists);
554
- },
555
- }),
556
- *
557
- *
558
- * ```
559
- */
560
502
  function mapNullFieldsToUndefined(obj) {
503
+ if (!obj) return;
561
504
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, value === null ? void 0 : value]));
562
505
  }
563
506
 
@@ -965,9 +908,9 @@ const createEnumImplementer = ({ db, schemaBuilder }) => {
965
908
  let enumSchemaName;
966
909
  let enumValues;
967
910
  if (tsName) {
968
- const schemaEnum = db._.schema[tsName];
911
+ const schemaEnum = db._.fullSchema[tsName];
969
912
  enumSchemaName = tsName.toString();
970
- const enumCol = Object.values(db._.schema).filter((s) => typeof s === "object").map((s) => Object.values(s.columns)).flat(2).find((s) => s.config?.enum === schemaEnum);
913
+ const enumCol = Object.values(db._.schema).filter((s) => typeof s === "object").map((s) => Object.values(s.columns)).flat(2).filter(isEnumSchema).find((e) => e.config.enum === schemaEnum);
971
914
  if (!enumCol) throw new RumbleError(`Could not find applied enum column for ${tsName.toString()}.
972
915
  Please ensure that you use the enum at least once as a column of a table!`);
973
916
  enumValues = enumCol.enumValues;