v1.0.0
Support Prisma-AppSync by Starring Our Repo!
🌟 Sponsor
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.
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
💛 Github Sponsors
Enjoy using Prisma-AppSync? Please consider 💛 Github sponsors.