Giter VIP home page Giter VIP logo

Comments (3)

wtrocki avatar wtrocki commented on June 4, 2024

I think we do not enable cascade deletes as form of precaution, but I get that this is inconvenient to delete all comments from end user app to delete post

Anyone can alter cascade rules on FK but that is like a lot of work if you have large db and on the other hand I do not want to have issue ala graphback deleted half of my database because we setup default cascades.

We need new annotations/ability probably so this is feature request IMHO

from graphback.

wtrocki avatar wtrocki commented on June 4, 2024

Actually I cannot replicate this. I see we do not put any so constraints by default. More info needed

from graphback.

rrguhan6 avatar rrguhan6 commented on June 4, 2024

Actually I cannot replicate this. I see we do not put any so constraints by default. More info needed

Flow to reproduce this issue

  1. create a note record
    Query:
mutation {
  createNote(input: { title: "the gql 2 !" }) {
    id
    title
  }
}

Output:

{
  "data": {
    "createNote": {
      "id": "2",
      "title": "the gql 2 !"
    }
  }
}

2.create a comment with noteId
query:

mutation {
  createComment(input: { noteId: 2, text: "wow " }) {
    id
    text
    note {
      id
      title
    }
  }
}

output:

{
  "data": {
    "createComment": {
      "id": "2",
      "text": "wow",
      "note": {
        "id": "2",
        "title": "the gql 2 !"
      }
    }
  }
}

3.Now delete the note record
query:

mutation {
  deleteNote(input: { id: 2 }) {
    id
    title
  }
}

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)=(2) 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/web3/node_modules/pg-protocol/src/parser.ts:357:11)",
            "    at Parser.handlePacket (/home/guhan/code/gql-postgress/web3/node_modules/pg-protocol/src/parser.ts:186:21)",
            "    at Parser.parse (/home/guhan/code/gql-postgress/web3/node_modules/pg-protocol/src/parser.ts:101:30)",
            "    at Socket.stream.on (/home/guhan/code/gql-postgress/web3/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
  }
}

I am using postgres - 11.10 , node - v10.19.0 and created graphql project using "npm init graphback" command.

from graphback.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.