This repository was archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
This repository was archived by the owner on Apr 17, 2023. It is now read-only.
How to set on delete cascade in .graphql file #2277
Copy link
Copy link
Open
Labels
questionFurther information is requestedFurther information is requested
Description
I'm using postgres 11.10
My model is
"""
@model
"""
type Note {
""" @id """
id: ID!
title: String!
description: String
"""
@oneToMany(field: 'note')
"""
comments: [Comment]
}
"""
@model(delete: true)
"""
type Comment {
""" @id """
id: ID!
text: String
description: String
}
type Query {
getDraftNotes: [Note]
}
Query :
mutation{
deleteNote(input:{id:1}){
id
title
description
}
}
output:
{
"errors": [
{
"message": "delete from \"note\" where \"id\" = $1 returning * - update or delete on table \"note\" violates foreign key constraint \"comment_noteid_foreign\" on table \"comment\"",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"deleteNote"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"length": 274,
"name": "error",
"severity": "ERROR",
"code": "23503",
"detail": "Key (id)=(1) is still referenced from table \"comment\".",
"schema": "public",
"table": "comment",
"constraint": "comment_noteid_foreign",
"file": "ri_triggers.c",
"line": "2797",
"routine": "ri_ReportViolation",
"stacktrace": [
"error: delete from \"note\" where \"id\" = $1 returning * - update or delete on table \"note\" violates foreign key constraint \"comment_noteid_foreign\" on table \"comment\"",
" at Parser.parseErrorMessage (/home/guhan/code/gql-postgress/web/node_modules/pg-protocol/src/parser.ts:357:11)",
" at Parser.handlePacket (/home/guhan/code/gql-postgress/web/node_modules/pg-protocol/src/parser.ts:186:21)",
" at Parser.parse (/home/guhan/code/gql-postgress/web/node_modules/pg-protocol/src/parser.ts:101:30)",
" at Socket.stream.on (/home/guhan/code/gql-postgress/web/node_modules/pg-protocol/src/index.ts:7:48)",
" at Socket.emit (events.js:198:13)",
" at Socket.EventEmitter.emit (domain.js:448:20)",
" at addChunk (_stream_readable.js:288:12)",
" at readableAddChunk (_stream_readable.js:269:11)",
" at Socket.Readable.push (_stream_readable.js:224:10)",
" at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)"
]
}
}
}
],
"data": {
"deleteNote": null
}
}
pls help me to resolve this
Arenukvern
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested