prisma / prisma-admin-feedback

Feedback for Prisma Admin (currently in invite-only preview)
6 stars 1 forks source link

Empty row stuck in table #150

Closed aleksnied closed 4 years ago

aleksnied commented 4 years ago

I have a service running on a prisma dev server.

I had just changed the datamodel, adding some fields to one of my types. I cleared out all the objects of that type in the console to start from scratch with the data. That went ok.

I then proceeded to clear out another type that linked to this altered type. After selecting and deleting all rows of this other type via the console, I realised there was one row leftover: an empty row.

The admin console currently shows an error when I open this type in admin:

[ { "message": "Cannot return null for non-nullable type (line 5, column 5):\n user {\n ^", "path": [ "cartItems", 0, "user" ], "locations": [ { "line": 5, "column": 5 } ] } ]

I assume the problem is that the empty row has a null value for a required property- a link to the user type.

The empty row is visible in the table above normally populated rows. Clicking on it does not open the editing menu, there is no way to delete it.

Curiously, when I query this type in the playground, the query comes back ok, showing only the correct populated nodes.

I can't delete or edit this empty row, since I can't enter null values in its WhereUniqueInput.

Following engaging with your customer support, I tried clearing the browser cache for prisma, that didn't help.

Here is my data model. The type that was altered was Item and the type that is giving me trouble is CartItem:

enum Permission {
  ADMIN
  USER
  ITEMCREATE
  ITEMUPDATE
  ITEMDELETE
  PERMISSIONUPDATE
}

type User {
  id: ID! @id
  name: String!
  email: String! @unique
  password: String!
  resetToken: String
  resetTokenExpiry: Float
  permissions: [Permission!]! @scalarList(strategy: RELATION)
  cart: [CartItem]! @scalarList(strategy: RELATION)
}

type Item {
  id: ID! @id
  title: String!
  description: String!
  image: String
  largeImage: String
  price: Int!
  user: User!
  createdAt: DateTime! @createdAt
  updatedAt: DateTime! @updatedAt
}

type CartItem {
  id: ID! @id
  quantity: Int! @default(value: 1)
  user: User!
  item: Item
}

type OrderItem {
  id: ID! @id
  title: String!
  description: String!
  image: String
  largeImage: String
  price: Int!
  quantity: Int! @default(value: 1)
  user: User!
}

type Order {
  id: ID! @id
  items: [OrderItem!]! @scalarList(strategy: RELATION)
  total: Int!
  user: User!
  charge: String!
}
Screenshot 2019-08-01 at 08 58 04
sdnts commented 4 years ago

@aleksnied Could you delete this row from the Playground and see if that helps?

Alternativetly, if you open the query editor for this model (using the little arrow to the right of the model name, next to the Rerun button), and remove the problematic field from the query, I think you should be able to see the result without that column and delete it then.

Let me know if I misunderstood! :D

aleksnied commented 4 years ago

Hey!

Thanks for the reply. I couldn't delete this row in the playground because I couldn't fulfil its WhereUniqueInput! (Since it has no id)

But the other trick worked! I removed all required fields from the query, which allowed me to click the row in the result and delete it in the console. Now the main query with the required fields works.

Bit fiddly but that way round worked! Thanks :) You might want to look at being able to edit/delete rows that don't fulfil their requirements.

sdnts commented 4 years ago

@aleksnied Yep, we've been working on a few significant improvements, and I'll take that into account!