Issue: Schema generation issue when using Prisma `@@id` attributes.
robm94 opened this issue · 2 comments
robm94 commented
After adding a many to many relation I get the following error when running "npm run dev"
[vite-node] Failed to execute file:
GraphQLError: Syntax Error: Expected Name, found "}".
at syntaxError (folder_path/node_modules/prisma-appsync/dist/server/index.js:7:660)
at P5.expectToken (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:17588)
at P5.parseName (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:1728)
at P5.parseInputValueDef (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:11241)
at P5.optionalMany (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:18355)
at P5.parseInputFieldsDefinition (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:13613)
at P5.parseInputObjectTypeDefinition (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:13436)
at P5.parseDefinition (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:2517)
at P5.many (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:18474)
at P5.parseDocument (folder_path/node_modules/prisma-appsync/dist/server/index.js:22:1904) {
path: undefined,
locations: [ { line: 370, column: 5 } ],
extensions: [Object: null prototype] {
The output of the schema.gpl file looks wrong it has a lot of indents and spaces that should not be there.
Here is the schema.prisma file I used.
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
generator appsync {
provider = "prisma-appsync"
}
model Post {
id Int @id @default(autoincrement())
title String
categories CategoriesOnPosts[]
}
model Category {
id Int @id @default(autoincrement())
name String
posts CategoriesOnPosts[]
}
model CategoriesOnPosts {
post Post @relation(fields: [postId], references: [id])
postId Int // relation scalar field (used in the `@relation` attribute above)
category Category @relation(fields: [categoryId], references: [id])
categoryId Int // relation scalar field (used in the `@relation` attribute above)
assignedAt DateTime @default(now())
assignedBy String
@@id([postId, categoryId])
}
maoosi commented
Thanks for reporting @robm94!
The issue seems related to @@id([postId, categoryId])
as replacing it with a classic id Int @id @default(autoincrement())
solves the issue.
Will look into it and hopefully ship a fix with the next release.
maoosi commented
Fix released with 1.0.0-rc.7.