Skip to content

Releases: maoosi/prisma-appsync

v1.0.2

11 Jan 13:14
Compare
Choose a tag to compare

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

🪵 Changelog

  • Fix issue #170: Nested CreateWithout[Relation]Input requires mandatory ID fields despite create or connectOrCreate usage. Thanks to @StephanDecker for reporting and helping test the fix!

🌟 Sponsor

Kuizto — The Everyday Cooking App

Kuizto.co is a cooking app that adds a unique twist to everyday cooking. Netflix-like feed to explore tailored recipes. Get inspired by others, save to cooklists, plan instantly!

v1.0.1

09 Jan 04:16
Compare
Choose a tag to compare

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

🪵 Changelog

  • Fix: Generator crashing with @default("string") in Prisma schema definitions. Thanks @Tenrys for reporting the issue!

🌟 Sponsor

Kuizto — The Everyday Cooking App

Kuizto.co is a cooking app that adds a unique twist to everyday cooking. Netflix-like feed to explore tailored recipes. Get inspired by others, save to cooklists, plan instantly!

v1.0.0

03 Jan 00:08
Compare
Choose a tag to compare

Support Prisma-AppSync by Starring Our Repo!

🌟 Sponsor

Kuizto — The Everyday Cooking App

Kuizto.co is a cooking app that adds a unique twist to everyday cooking. Netflix-like feed to explore tailored recipes. Get inspired by others, save to cooklists, plan instantly!

🚀 Release Summary

  • Prisma-AppSync officially stable! 🎉
  • Breaking change to context alias values
  • Breaking change to maximum query depth defaults
  • Enhanced @gql and @auth directives for finer control
  • Generator Revamp & New Diff Tool for improved GraphQL Schema output
  • Streamlined Model Relations: Create[Model]Without[Relation]Input
  • Default input values are now visible in your GraphQL IDE
  • Added support for AWS_LAMBDA authorization mode

👀 Full Changelog

👉 Prisma-AppSync officially stable! 🎉

Exciting news! Prisma-AppSync has achieved stability and is already in use in multiple production projects. Time to celebrate the release of v1.0.0!

👉 Breaking change to context alias values

To streamline values in Context.alias (accessible from hooks and custom resolvers params), the modify alias has been renammed to mutate, and batchModify is now referred to as batchMutate.

👉 Breaking change to maximum query depth defaults

To align maximum query depth with the latest changes from v1.0.0, the maxDepth default value was changed from 3 to 4.

To limit side effects, you have the option to manually set it to its previous value via:

const prismaAppSync = new PrismaAppSync({ maxDepth: 3 })

👉 Enhanced @gql and @auth directives for finer control

The @gql directive has been updated to provide more detailed control over CRUD operations:

// before: only top-level rules were supported
@gql(queries: null, mutations: null)

// after: define specific rules for each CRUD operation
@gql(queries: { list: null, count: null }, mutations: { update: null, delete: null })

Same goes with the @auth directive, allowing granular access rules per operation:

// before: only top-level rules were supported
@auth(queries: [{ allow: iam }])

// after: individual rules for specific query operations
@auth(queries: { list: [{ allow: iam }] })

Field-level authorization is now possible with the @auth directive:

// newly supported field-level authorization rules
@auth(fields: { password: [{ allow: apiKey }] })

The defaultDirective in the prisma-appsync generator config is now optional, providing flexibility in configurations:

generator appsync {
  provider = "prisma-appsync"
  // `defaultDirective` can be specified or omitted
  defaultDirective = "@auth(model: [{ allow: iam }])"
}

When provided, defaultDirective seamlessly integrates with model-specific directives:

// specified 'defaultDirective' for all models:
@auth(model: [{ allow: iam }])

// additional 'model directive' for enhanced control:
@auth(model: [{ allow: apiKey }])

// resulting merged directive for the model:
@auth(model: [{ allow: iam }, { allow: apiKey }])

👉 Generator Revamp for improved GraphQL Schema output

The Generator package has been totally rewritten to address reported issues and unlock a slew of new features. This not only makes the GraphQL Schema output more concise and well-optimized but also ensures Prisma-AppSync is ready for what's next.

With the largest production schemas, this revamp has led to a reduction of up to 500 lines in the GraphQL Schema output.

::: info Free online tool: AppSync GraphQL Schema Diff
To see the before/after with your own schema or simply compare two different AppSync Schemas, we've published a free online tool: AppSync GraphQL Schema Diff.
:::

👉 Streamlined Model Relations: Create[Model]Without[Relation]Input

With the generator revamp, you can now create, update, or upsert any Model Relation (like Author) tied to a particular Model (such as Post) in just one GraphQL query. This eliminates the previous, more cumbersome process of inserting each Model separately and then manually associating them. The improvement is in sync with the Prisma Client API, offering a more streamlined and developer-friendly approach.

mutation {
  createPost(
    data: {
      title: "Example post"
      author: {
        connectOrCreate: {
          where: { name: "John Doe" }
          create: { name: "John Doe" }
        }
      }
    }
  ) {
    title
    author {
      name
    }
  }
}

👉 Default input values are now visible in your GraphQL IDE

Considering the Prisma model example below:

model Post {
  content     String
  views       Int @default(0)
  isPublished Boolean @default(false)
}

This model will result in the following GraphQL schema:

input PostCreateInput {
  content: String!
  views: Int = 0
  isPublished: Boolean = false
}

This update automatically fills the default values for views (0) and isPublished (false) in your GraphQL IDE, making it easier to see and work with your schema defaults.

👉 Added support for AWS_LAMBDA authorization mode

You can now utilize AWS_LAMBDA as an authorization mode with the @auth directive:

// AWS_LAMBDA
@auth(model: [{ allow: lambda }])

🙏 Credits

Sylvain
Sylvain

🐙 💻 🤔 📖

💛 Github Sponsors

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

1.0.0-rc.7.2

12 Aug 05:40
Compare
Choose a tag to compare

🌟 Support Prisma-AppSync by Starring Our Repo!

Fixes and improvements

Sponsors

kuizto.co
Reconnect with home cooking

Credits

Nhu Mai
Nhu Mai

💻

Github sponsors

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

1.0.0-rc.7.1

08 Aug 00:38
Compare
Choose a tag to compare

🌟 Support Prisma-AppSync by Starring Our Repo!

Fixes and improvements

Sponsors

kuizto.co
Reconnect with home cooking

Credits

Michael Chan
Michael Chan

💻

Github sponsors

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

1.0.0-rc.7

07 Aug 03:29
Compare
Choose a tag to compare

🌟 Support Prisma-AppSync by Starring Our Repo!

Highlights

Local Dev Server Transitioned to Amplify AppSync Simulator

🚨 Breaking Change: Please Read the Following Carefully Before Upgrading.

The previous version of our Prisma-AppSync local development server relied on GraphQL Yoga, complemented by several custom functions to mimic AWS Lambda and AppSync's internal behaviors. This was an effective approach initially but began to cause issues as Prisma-AppSync was used for more complex use cases.

To resolve these issues and simplify maintenance, we've opted to replace our bespoke implementation with Amplify AppSync Simulator. Amplify AppSync Simulator is an integral package within the AWS Amplify CLI and aims to accurately simulate the experience of using AppSync locally.

This migration brings numerous advantages to using the local development server:

  • Enables the use of Codegen Issue #137
  • Supports using GraphQL Fragments Issue #112
  • Accommodates Authentication and Authorization modes provided by AWS AppSync, including Cognito User Pools.
  • Enables Subscription support, using a local WebSocket server.

For users already using the Prisma-AppSync local development server who wish to migrate, follow these steps:

  1. Substitute your local server.ts file with the newer version found at packages/boilerplate/server.ts.
  2. Install the new required dependency using yarn add js-yaml -D.
  3. Modify the CLI command to initiate the local development server within your package.json file (by default, this is the dev script).
  4. Here are the corresponding before and after scripts:
# before
npx vite-node ./server.ts --watch --
    --handler handler.ts
    --schema prisma/generated/prisma-appsync/schema.gql
    --port 4000
    --watchers '[{"watch":["**/*.prisma","*.prisma"],"exec":"npx prisma generate && touch ./server.ts"}]'
    --headers '{"x-fingerprint":"123456"}' # removed

# after
npx vite-node ./server.ts --watch --
    --handler handler.ts
    --schema prisma/generated/prisma-appsync/schema.gql
    --resolvers prisma/generated/prisma-appsync/resolvers.yaml # added
    --port 4000
    --wsPort 4001 # added
    --watchers '[{"watch":["**/*.prisma","*.prisma"],"exec":"npx prisma generate && touch ./server.ts"}]'

Upgraded to Prisma 5.1.1+

🚨 Breaking Change: Please Read the Following Carefully Before Upgrading.

Prisma-AppSync internals were updated to support Prisma 5.1.1. One potentially breaking change is that the extendedWhereUnique preview feature was promoted to general availability. So newly generated WhereUniqueInput schema types exposes all fields on the model, not just unique fields.

Updated Minimum NodeJS Version Requirement

🚨 Breaking Change: Please Read the Following Carefully Before Upgrading.

The compilation target of Prisma-AppSync was updated from Node.js 14 to Node.js 16. Please ensure you have the minimum required Node.js version (Node.js 16) enabled on your local environment and deployed Lambda function.

Updated CDK Boilerplate

The provided CDK Boilerplate has been updated to use the latest depdencies and recommended CDK packages. In addition, the default Lambda function version has been updated to use Node 18.X.

Fixes and improvements

Sponsors

kuizto.co
Reconnect with home cooking

Credits

Sylvain
Sylvain

🐙 💻 🤔 📖
Tom
Tom

💻 🤔
Bell
Bell

💻 🤔
Max Konin
Max Konin

💻

Github sponsors

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

1.0.0-rc.6

22 Apr 05:11
Compare
Choose a tag to compare

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

🚨 This release include breaking changes, so please make sure to read the below thoroughly before upgrading.

Breaking

💔 Updated upsert<Model> mutation params to be similar to Prisma Client API

This change is considered breaking if you are using upsert mutations.

# before
mutation {
  upsertPost(
    where: { id: 1 }
    data: { title: "Hello world" }
  ) {
    title
  }
}

# after
mutation {
  upsertPost(
    where: { id: 1 }
    create: { title: "Hello world" }
    update: { title: "Hello world" }
  ) {
    title
  }
}

💔 Updated QueryParams.paths format to fix various reported issues on Shield ACL rules

This change fixes various reported issues on Shield ACL rules. See full details here. It also allows creating more granular rules such as createPost/**/connect{,/**}.

Only considered breaking if you have implemented advanced fine-grained access control rules, or if you are using QueryParams.paths for some custom business logic (most likely inside Hooks).

Example:

mutation createPost {
  createPost(
    data: {
      title: "Hello people"
      author: { connect: { id: 1 } }
    }
  ) {
    id
    title
  }
}

Before:

{
    "paths": [
        "/create/post/title",
        "/create/post/author/id",
        "/get/post/id",
        "/get/post/title"
    ]
}

After:

{
    "paths": [
        "createPost",
        "createPost/title",
        "createPost/author",
        "createPost/author/connect",
        "createPost/author/connect/id",
        "getPost",
        "getPost/id",
        "getPost/title"
    ]
}

Highlights

⚡️ Support for custom GraphQL scalars on fields

Prisma schema:

/// @gql(scalars: { website: "AWSURL" })
model Company {
  id       Int    @id @default(autoincrement())
  name     String
  website  String?
}

GraphQL output:

type Company {
    id: Int!
    name: String!
    website: AWSURL
}

⚡️ Support for nullable in Query filters

Example #1:

query {
  listUsers (
    where: {
      fullname: { isNull: true }
    }
  ) {
    id
  }
}

Example #2:

query {
  listPosts (
    where: {
      author: { is: NULL }
    }
  ) {
    id
  }
}

Example #3:

query {
  listPosts (
    where: {
      author: { isNot: NULL }
    }
  ) {
    id
  }
}

⚡️ Refreshed documentation

Prisma-AppSync documentation has been refreshed with new navigation, revised content, and a new guide on Tweaking the GraphQL Schema.

Fixes and improvements

Sponsors

kuizto.co
Solve and sparkle up your daily food life
travistravis.co
Collaborative travel planning

Credits

Sylvain
Sylvain

🐙 💻 🤔 📖
Bell
Bell

💻 🤔
Tom
Tom

💻 🤔
jeremy-white
jeremy-white

💻

Annoucements

Sylvain I am starting my Founder journey with kuizto.co. Kuizto is a bit like Netflix for your daily food! Lots of visual cooking inspiration, auto-generated grocery lists, and a small social layer to share and discover deliciously simple meals. Please register for early access, launching later this year!

Sylvain Prisma-EdgeQL is an edge-compatible Prisma Client (using PlanetScale driver). The project was initially built as part of my work at kuizto.co and will be released open-source soon. Please go Star the repo if you are interested!

Github sponsors

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

1.0.0-rc.5

08 Jan 05:58
Compare
Choose a tag to compare

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

Highlights

⚡️ Async shield rules

Async Shield rules are now supported in Prisma-AppSync, opening up to 3 different ways to define fine-grained access control rules:

return await prismaAppSync.resolve({
    event,
    shield: () => {
        return {
            // Boolean
            'listPosts{,/**}': { rule: true },

            // Function
            'listPosts{,/**}': { rule: () => true },

            // (NEW) Async Function
            'listPosts{,/**}': {
                rule: async () => {
                    await sleep(1000)
                    return true
                },
            },
        }
    },
})

⚡️ Support for deeply nested relation filters

Deeply nested relation filters are now supported in Prisma-AppSync, allowing to perform the following queries:

query {
  listComments(
    where: {
      author: {
  
        # deeply nested relation filter
        posts: {
          every: {
            published: { equals: true }
          }
        }

      }
    }
  )
}
query {
  listUsers(
    where: {
      posts: {
        every: {

          # deeply nested relation filter
          comments: {
            every: {
              message: { startsWith: 'hello' }
           }
          }

        }
      }
    }
  )
}

⚡️ Support for extendedWhereUnique preview feature

Using the extendedWhereUnique preview feature flag will enable filtering on non-unique fields in Prisma-AppSync, allowing to do the following:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["extendedWhereUnique"]
}
mutation($id: Int!, $version: Int) {
  updatePost(
    # version is a non-unique field
    where: { id: $id, version: { equals: $version } },
    operation: { version: { increment: 1 } }
  ) {
    id
    version
  }
}

See Prisma Docs for more details.

Fixes and improvements

Credits

Sylvain
Sylvain

🧙‍♂️ 💻 🤔 📖
Ciprian Caba
Ciprian Caba

💻 🤔
Bell
Bell

💻

Github sponsors

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

1.0.0-rc.4

21 Dec 08:03
Compare
Choose a tag to compare

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

Highlights

⚡️ Local dev server is now using vite-node instead of ts-node-dev

Due to some incompatibilities between ts-node-dev and some of the newest changes, Vite is now used as the underlying Node runtime for the Prisma-AppSync local dev server.

To migrate an existing project using the local dev server, you'll need to edit the dev script inside your package.json and replace the following part:

npx ts-node-dev --rs --transpile-only --watch './*.ts' -- ./server.ts

with:

npx vite-node ./server.ts --watch --

⚡️ Local dev server upgraded to GraphQL Yoga v3, with the ability to use custom options

When using Prisma-AppSync local dev server, it is now possible to pass custom options from the server.ts file.

createServer({
    yogaServerOptions: {
        cors: {
            origin: 'http://localhost:4000',
            credentials: true,
            allowedHeaders: ['X-Custom-Header'],
            methods: ['POST']
        }
        /* ...other args */
    }
})

For the full list of supported options, please refer to https://the-guild.dev/graphql/yoga-server/docs and the createYoga method.

Fixes and improvements

Credits

Sylvain
Sylvain

🧙‍♂️ 💻 🤔 📖
Ciprian Caba
Ciprian Caba

💻 🤔
Cameron Jenkinson
Cameron Jenkinson

💻
Bell
Bell

💻

Github sponsors

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

1.0.0-rc.3

14 Nov 08:05
Compare
Choose a tag to compare

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

Fixes

Credits

Sylvain
Sylvain

🧙‍♂️ 💻 🤔 📖

Github sponsors

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