Describe the bug
Errors:
Global
✖ An unknown error happened: java.lang.ClassCastException: com.prisma.shared.models.TypeIdentifier$Relation$ cannot be cast to com.prisma.shared.models.TypeIdentifier$ScalarTypeIdentifier
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would expect the deploy to happen.
Versions (please complete the following information):
@guigaoliveira
Can you please share your datamodel.prisma and prisma.yml files so that we can reproduce this issue? Right now with the provided information, it is not possible to reproduce the issue and triage the bug.
prisma.yml
endpoint: http://localhost:5001
datamodel:
- entities/user.graphql
- entities/project.graphql
- entities/version.graphql
generate:
- generator: javascript-client
output: ./generated/prisma-client/
- generator: graphql-schema
output: ./generated/graphql-schema/prisma.graphql
hooks:
post-deploy:
- prisma generate
seed:
run: node ./seed.js
entities/user.graphql
enum UserRole {
USER
COMPANY
}
type User {
id: ID! @unique @id
name: String!
username: String @unique
email: String! @unique
password: String!
role: UserRole @default(value: COMPANY)
isDeleted: Boolean! @default(value: false)
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
entities/project.graphql
type Project {
id: ID! @id @unique
name: String!
description: String! @default(value: "")
versions: [Version!]! @default(value: [])
owner: User!
isDeleted: Boolean! @default(value: false)
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
entities/version.graphql
type Version {
id: ID! @id @unique
tag: String!
project: Project!
file: String @default(value: "")
isRealised: Boolean! @default(value: false)
isDeleted: Boolean! @default(value: false)
createdAt: DateTime! @createdAt
updatedAt: DateTime! @createdAt
}
I think the problem is in the "versions: [Version!]! @default(value: [])" in this case.
@guigaoliveira
You can remove that. It will be [] by default without the directive
Okay, but a more appropriate error message would be interesting.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.
I have a similar issue when deploying my introspected schema, what's the best way to debug on my side?
My error:
Global
✖ An unknown error happened: java.lang.ClassCastException: com.prisma.shared.models.TypeIdentifier$Relation$ cannot be cast to com.prisma.shared.models.TypeIdentifier$ScalarTypeIdentifier
My data schema is quite large, and has multiple relation tables. I'll just include one for example:
type Source @db(name: "sources") {
source_id: Int! @id
content: [Content]
description: String!
name: String!
sourceRuns: [SourceRun]
standardizations: [Standardization]
transformClassName: String! @db(name: "transform_class_name")
url: String!
validAtUtc: DateTime! @db(name: "valid_at_utc") @default(value: "CURRENT_TIMESTAMP")
}
type SourceRun @db(name: "source_runs") @relationTable {
id: Int! @id
run: Run! @db(name: "run_id")
source: Source! @db(name: "source_id")
}
type Run @db(name: "runs") {
id: Int! @id
approved: Boolean
atUtc: DateTime! @db(name: "at_utc") @default(value: "CURRENT_TIMESTAMP")
groupId: String! @db(name: "group_id")
sourceRuns: [SourceRun]
}
The error seems to indicate there's an issue with a relation, but nothing more. What next?
type Source @db(name: "sources") {
source_id: Int! @id
content: [Content]
description: String!
name: String!
sourceRuns: [SourceRun]
standardizations: [Standardization]
transformClassName: String! @db(name: "transform_class_name")
url: String!
validAtUtc: DateTime! @db(name: "valid_at_utc")
}
type SourceRun @db(name: "source_runs") @relationTable {
id: Int! @id
run: Run! @db(name: "run_id")
source: Source! @db(name: "source_id")
}
type Run @db(name: "runs") {
id: Int! @id
approved: Boolean
atUtc: DateTime! @db(name: "at_utc")
groupId: String! @db(name: "group_id")
sourceRuns: [SourceRun]
Try removing the default statements
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.
@harveyramer @pantharshit00
I've had this same issue where I can't "Prisma deploy" because of these global errors. I have a massive introspected schema as well with all of the above errors. I made a copy of the db and am putting it together slowly in another datamodel.graphql file. np... But I have another issue. Which I'm thinking can't be solved. The issue is creating relationships with the introspected schema without referencing the MySQL relationship with "@db(name: __id__). Not being able to make queries or mutations happen using a pure simple relationship. Forcing us basically to the MySQL tables and being stuck to that structure.
It's more like ...the way to write myGraphQL*.
Let me know if you know how to create new graphql relationships without migrating the database?
What do you think about micro servicing your MySQL into multiple instances? You would still run your main MySQL for everything but gradually unpack your tables into simple databases. You could open up new routes with Nginx and deal with smaller databases and their individual problems, by adjusting small sections of frontend and backend code at a time to handle the return of the data. Into the new databases.