Skip to content

Releases: maoosi/prisma-appsync

1.0.0-rc.2

11 Nov 04:57
Compare
Choose a tag to compare

🌟 Help us spread the word about Prisma-AppSync by starring the repo.

Major improvements

Support for Prisma Fluent API syntax on Relation Filters

🚨 Breaking change affecting syntax for Relation Filters.

In this release, we are changing how to write relation filters. We are replacing the original Prisma Client syntax (using is and isNot filters) with the newest Fluent API syntax which feels more natural to write, but also allows using more complex Relation Filters such as contains, endsWith, equals, gt, gte, lt, lte, in, not, notIn and startsWith.

Before

query {
 listPosts(
  where: {
   author: { is: { username: "xxx" } }
  }
 ) {
  title
  author { username }
 }
}

After

query {
 listPosts(
  where: {
   author: { username: { equals: "xxx" } }
  }
 ) {
  title
  author { username }
 }
}

Improved readability for underlying Prisma client errors

In this release, we have improved readability for all known errors thrown by the underlying Prisma Client. For example, using an incorrect connection URL (DATABASE_URL) will now return the below message as part of the API response:

Error with Prisma client initialization. https://www.prisma.io/docs/reference/api-reference/error-reference#prismaclientinitializationerror

The full error trace will still appear inside the terminal and/or CloudWatch logs.

New documentation guide: "Adding Hooks"

In this release, we have added a new guide on "Adding Hooks". Particularly useful to trigger actions and/or manipulate data before or after queries.

https://prisma-appsync.vercel.app/advanced/hooks.html

Example snippet:

return await prismaAppSync.resolve<'likePost'>({
    event,
    hooks: {
        // execute before any query
        'before:**': async (params: BeforeHookParams) => params,

        // execute after any query
        'after:**': async (params: AfterHookParams) => params,

        // execute after custom resolver query `likePost`
        // (e.g. `query { likePost(postId: 3) }`)
        'after:likePost': async (params: AfterHookParams) => {
            await params.prismaClient.notification.create({
                data: {
                    event: 'POST_LIKED',
                    targetId: params.args.postId,
                    userId: params.authIdentity.sub,
                },
            })
            return params
        },
    },
})

Fixes

Credits

Sylvain
Sylvain

🧙‍♂️ 💻 🤔 📖
Ciprian Caba
Ciprian Caba

💻 🤔

Github sponsors

Enjoy using Prisma-AppSync? Please consider 💛 Github sponsors.

1.0.0-rc.1

26 Oct 08:59
Compare
Choose a tag to compare

Prisma-AppSync 1.0.0-rc.1

🚨 This release comes with a major rewrite of the Prisma-AppSync Client API and breaking changes. Please make sure to take a moment and read through the details below before upgrading.

🤯 Major changes

  • Codebase rewrite: Prisma-AppSync was rewritten from the ground to offer a simplified API with a more opinionated approach, end-to-end type safety for a better DX, advanced customisation options, as well as improved security and fine-grained access control.
  • Installer CLI: New interactive scaffolding CLI to quickly start new Prisma-AppSync projects, accessible from a single npx create-prisma-appsync-app command. It can also plug into existing projects already using Prisma.
  • Local AppSync Server: New local development environment built for Prisma-AppSync (local database, auto-reload, TS support, GraphQL IDE). Iterate faster by simulating a GraphQL API running on AWS AppSync from your local machine.
  • Documentation website: New documentation website and contribution guide, built upon VitePress, and accessible from prisma-appsync.vercel.app.
  • Lots of improvements: Implemented dozens of improvements, bug fixes and new Prisma features (atomic operations, order by relations, case sensitivity, etc).

🔎 Full changelog

See full changelog here.

💛 Github sponsors

Enjoy using Prisma-AppSync? Please consider supporting me.

1.0.0-beta.58.2

25 Jun 07:30
Compare
Choose a tag to compare
1.0.0-beta.58.2 Pre-release
Pre-release

⚠️ (Breaking) Fix: Issue linked to Prisma models naming

Using a model name format other than PascalCase OR already in the plural form, was causing mapping issues between GraphQL queries and Prisma Client.

This feature is only breaking in case you were NOT following PascalCase naming convention for models OR affected by one of the below examples.

Before

  • Model person: GQL types generated were not using camelCase (getperson, listpersons, etc...)
  • Model People: Was wrongly mapping to singular person instead of people.
  • Model PersonEmails: Was wrongly mapping to prismaClient.personemail instead of prismaClient.personemails
  • Model person_emails: Was throwing an error when calling the API.

After

  • Model person: GQL types are now properly using camelCase (getPerson, listPersons, etc...)
  • Model People: Mapping back to the right people model.
  • Model PersonEmails: Mapping back to the right prismaClient.personemails
  • Model person_emails: Properly converted to getPersonEmails and mapped back to prismaClient.person_emails

⚠️ (Breaking) Feat: orderBy query filter updated to support multiple fields

Before

query {
    listPosts(orderBy: { title: ASC }) {
        title
    }
}

After

query {
    listPosts(
        orderBy: [
            { title: ASC },
            { preview: ASC },
        ]
    ) {
        title
    }
}

🆕 Feat: New Queries, Mutations and Subscriptions added

# New `createMany` mutation (example for Post model)
mutation {
    createManyPosts(
        data: [
            { title: "How to get started with Prisma-AppSync" }
            { title: "How to migrate to Prisma-AppSync" }
        ]
    ) {
        count
    }
}

# New `updateMany` mutation (example for Post model)
mutation {
    updateManyPosts(
        where: { title: { startsWith: "How to" } }
        data: { category: "guides" }
    ) {
        count
    }
}

# New `count` query (example for Post model)
query {
    countPosts(
        where: { title: { startsWith: "How to" } }
    )
}

# New `onUpserted` subscription (example for Post model)
# > Triggered from `upsertPost` mutation.
subscription {
    onUpsertedPost {
        title
        category
    }
}

# New `onMutated` subscription (example for Post model)
# > Triggered from ANY SINGLE record mutation (excl. `on*ManyPosts`).
subscription {
    onMutatedPost {
        title
        category
    }
}

# New `on[Action]Many` subscriptions (example for Post model)
subscription { onCreatedManyPosts { count } }
subscription { onUpdatedManyPosts { count } }
subscription { onDeletedManyPosts { count } }

# New `onMutatedMany` subscription (example for Post model)
# > Triggered from ANY MULTIPLE records mutation (excl. single record mutations).
subscription { onMutatedManyPosts { count } }

🆕 Misc

  • The authIdentity property (accessible from the hooks) now includes requestApiKey and requestUserAgent when using API_KEY authorization.
  • Comments added in the generate GraphQL schema (visible from AppSync query editor docs).
  • Updated Boilerplate to reflect new changes.
  • Updated generated API documentation to reflect new changes.
  • Upgraded Prisma to v2.25.0.

1.0.0-beta.57

07 Jun 09:22
Compare
Choose a tag to compare
1.0.0-beta.57 Pre-release
Pre-release
  • Feat: Support for prisma ^2.24.1 added.
  • Fix: Type issue in the Boilerplate.

1.0.0-beta.56

02 May 08:19
Compare
Choose a tag to compare
1.0.0-beta.56 Pre-release
Pre-release

⚠️ Breaking

  • Feat: Introducing pagination on list queries.
  • Feat: Introducing entirely refactored filters on list queries, closer to the Prisma syntax.

Filtering (breaking)

To simplify both usage and implementation, filtering on fields and relations have been refactored entirely. The syntax is now closer to how Prisma handles filtering.

# before
query {
    listPosts(
        where: { title_startsWith: "Foo" }
    ) {
        title
    }
}

# after (1.0.0-beta.56+)
query {
    listPosts(
        where: { title: { startsWith: "Foo" } }
    ) {
        title
    }
}
# before
query {
    listPosts(
        where: { title: "Foo" }
    ) {
        title
    }
}

# after (1.0.0-beta.56+)
query {
    listPosts(
        where: { title: { equals: "Foo" } }
    ) {
        title
    }
}

Some Types have also been renamed for more consistency:

  • CreateRelations renamed to CreateRelationsInput
  • UpdateRelations renamed to UpdateRelationsInput
  • WhereInput renamed to WhereFilterInput

Pagination (breaking)

Introducing pagination on list queries (using Prisma offset pagination).

# after (1.0.0-beta.56+)
query {
    listPosts(
        skip: 0
        take: 20
    ) {
        title
    }
}

If the take parameter is omitted, PrismaAppSync will use a default value of 50. It is also possible to change the default value:

// Set the default value to 50, if the `take` parameter is omitted.
const app = new PrismaAppSync({
    connectionUrl: process.env.DB_CONNECTION_URL,
    defaultPagination: 20
})

// Disable pagination limit, if the `take` parameter is omitted.
const app = new PrismaAppSync({
    connectionUrl: process.env.DB_CONNECTION_URL,
    defaultPagination: false
})

Non-breaking

  • Fix: Has no exported member 'Prisma' issue resolved (issues/11)

1.0.0-beta.53

26 Apr 05:30
Compare
Choose a tag to compare
1.0.0-beta.53 Pre-release
Pre-release

⚠️ Breaking

Version 1.0.0-beta.52 introduced an issue with accessing Prisma client from inside a custom resolver. To address this, the customResolvers parameter has been removed from the PrismaAppSync constructor. Instead, PrismaAppSync now exposes a new registerCustomResolvers method:

// before
const app = new PrismaAppSync({
    connectionUrl: String(process.env.CONNECTION_URL),
    customResolvers: { incrementPostsViews }
})

// after (1.0.0-beta.53+)
const app = new PrismaAppSync({
    connectionUrl: String(process.env.CONNECTION_URL)
})
app.registerCustomResolvers({ incrementPostsViews })

See docs for more details.

Non-breaking

  • Feat: For contributors, running yarn create prisma-appsync-app . --test now also creates a custom resolver for testing purpose.
  • Fix: PNPM install not running prisma generate by default (issues/11)

1.0.0-beta.52

25 Apr 09:53
Compare
Choose a tag to compare
1.0.0-beta.52 Pre-release
Pre-release

⚠️ Breaking

  • Feat: Providing easier access to Prisma Client
// initialise client
const app = new PrismaAppSync({
    connectionUrl: process.env.CONNECTION_URL
})

// access Prisma client
app.prisma.$use(async (params, next) => {
  console.log('This is middleware!')
  return next(params)
})

Migration guide:

  • app.$disconnect replaced with app.prisma.$disconnect.
  • prisma parameter removed from the before and after hooks functions, as well as from the customResolvers parameters. To access prisma from within hooks, directly use app.prisma.

Non-breaking

  • Feat: Support for prisma ^2.21.2 added.
  • Feat: Lambda bundle size reduced (provided CDK boilerplate).
afterBundling(inputDir: string, outputDir: string): string[] {
    return [
        'npx prisma generate', 
        'rm -rf node_modules/@prisma/engines', 
        'rm -rf node_modules/@prisma/client/node_modules', 
        'rm -rf node_modules/.bin', 
        'rm -rf node_modules/prisma',
        'rm -rf node_modules/prisma-appsync',
    ]
}
  • Feat: Contribution guide added (see CONTRIBUTING.md) with new boilerplate testing workflow.
  • Feat: Core library is now using Pnpm instead of Yarn.

1.0.0-beta.51

03 Apr 14:01
Compare
Choose a tag to compare
1.0.0-beta.51 Pre-release
Pre-release
  • Fix: Support for prisma ^2.20 added (output for generators can now be env vars).
  • Feat: Ability to exclude fields and models from the generated GraphQL schema and API using /// @PrismaAppSync.ignore (more details in the docs).
  • Feat: Simpler boilerplate usage with yarn create prisma-appsync-app <target-folder>.

1.0.0-beta.49

08 Mar 05:54
Compare
Choose a tag to compare
1.0.0-beta.49 Pre-release
Pre-release
🏷️ Types refactoring