Skip to content

v0.8.0

Choose a tag to compare

@xcfox xcfox released this 10 Mar 17:45
· 898 commits to main since this release

GQLoom v0.8.0 Release Notes

Release Date: 2025-03-11

This release introduces several new features, improvements, and breaking changes across the @gqloom/core, @gqloom/federation, @gqloom/prisma, and @gqloom/drizzle packages. Below is a summary of the notable changes.


Core Changes (@gqloom/core)

🚀 Features

  • Enhanced Data Loading: Added field.load() to simplify data loading using data loaders.

    const bookResolver2 = resolver.of(Book, {
      books: query(v.array(Book)).resolve(() => books),
    
      author: field(v.nullish(User)).load(async (books) => {
        const usersIds = new Set(books.map((book) => book.authorId))
        const users: IUser[] = await db.users.findMany({
          where: { id: { in: usersIds } },
        })
        const usersMap = new Map(users.map((user) => [user.id, user]))
        return books.map((book) => usersMap.get(book.authorId))
      }),
    })
  • Chaining Resolver Factory: Introduced chaining resolver factory for more flexible resolver configurations.

  • Improved Type Inference: Enhanced type inference for silk.

🚨 Breaking Changes

  • Middleware Options Rename: Renamed MiddlewareOptions.type to MiddlewareOptions.operation.
  • Removed createLoom: Removed createLoom from @gqloom/core.

Federation Changes (@gqloom/federation)

🚀 Features

  • Chaining Resolver Factory: Added support for chaining resolver factory in federation schemas.
    import { resolver } from "@gqloom/federation"
    const userResolver = resolver
      .of(User, {
        me: query(User, () => ({ id: "1", name: "@ava" })),
      })
      .use(someMiddleware)
      .directives({ key: { fields: "id", resolvable: true } })
      .resolveReference(({ id }) => ({ id, name: "@ava" }))
    
    const userExecutor = userResolver.toExecutor()

Prisma Changes (@gqloom/prisma)

🚀 Features

  • Chaining Method for Custom Inputs and Middleware: Added support for chaining methods to add custom inputs and middleware to PrismaResolverFactory. Example:
    const postResolver = resolver.of(Post, {
      createPost: postResolverFactory.createMutation().use(async (next) => {
        const user = await useAuthedUser()
        if (user == null) throw new GraphQLError("Please login first")
        return next()
      }),
    
      author: postResolverFactory.relationField("author"),
    
      authorId: field.hidden,
    })

Drizzle Changes (@gqloom/drizzle)

🚀 Features

  • Chaining Method for Custom Inputs and Middleware: Added support for chaining methods to add custom inputs and middleware to drizzleResolverFactory. Example:
    export const usersResolver = resolver.of(users, {
      user: usersResolverFactory.selectSingleQuery().input(
        v.pipe(
          v.object({ id: v.number() }),
          v.transform(({ id }) => ({ where: eq(users.id, id) }))
        )
      ),
      users: usersResolverFactory.selectArrayQuery(),
      posts: usersResolverFactory.relationField("posts"),
    });

🚨 Breaking Changes

  • Removed DrizzleResolverFactory.create: Replaced DrizzleResolverFactory.create with drizzleResolverFactory.

Upgrade Guide

  1. Review Breaking Changes: Ensure your codebase accounts for the renaming of MiddlewareOptions.type to MiddlewareOptions.operation and the removal of createLoom in @gqloom/core.
  2. Update Drizzle Resolver Factory Usage: Replace any usage of DrizzleResolverFactory.create with drizzleResolverFactory.
  3. Test Your Resolvers: Verify that your resolvers function correctly with the new chaining methods and updated type inference.

Full Changelog: 0.7.0...v0.8.0

If you encounter any issues or have questions about these updates, please don't hesitate to reach out via our GitHub Issues.

Thank you for using GQLoom! We hope these improvements enhance your development experience.