prisma / prisma-admin-feedback

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

Can't save the new type after changing the datamodel #133

Open Oxyrus opened 5 years ago

Oxyrus commented 5 years ago

Describe the bug

I was following along the Get Started doc.

I had this datamodel:

type User {
  id: ID! @id
  username: String! @unique
  email: String! @unique
  password: String!
  name: String!
}

And it was updated to:

type User {
  id: ID! @id
  username: String! @unique
  email: String! @unique
  password: String!
  name: String!
  posts: [Post!]!
}

type Post {
  id: ID! @id
  title: String!
  published: Boolean! @default(value: false)
  author: User @relation(link: INLINE)
}

I deployed the changes with $ prisma deploy and re-generated the prisma client with $ prisma generate. I was also using apollo server to communicate with prisma, but after the changes it broke producing the following error message:

> vulture@1.0.0 start E:\Code\vulture
> node index.js

E:\Code\vulture\node_modules\graphql\language\parser.js:1433
  throw (0, _error.syntaxError)(lexer.source, token.start, "Expected ".concat(kind, ", found ").concat((0, _lexer.getTokenDesc)(token)));
  ^
GraphQLError: Syntax Error: Expected Name, found :
    at syntaxError (E:\Code\vulture\node_modules\graphql\error\syntaxError.js:24:10)
    at expectToken (E:\Code\vulture\node_modules\graphql\language\parser.js:1433:32)
    at parseName (E:\Code\vulture\node_modules\graphql\language\parser.js:98:15)
    at parseFieldDefinition (E:\Code\vulture\node_modules\graphql\language\parser.js:870:14)
    at many (E:\Code\vulture\node_modules\graphql\language\parser.js:1524:16)
    at parseFieldsDefinition (E:\Code\vulture\node_modules\graphql\language\parser.js:859:50)
    at parseObjectTypeDefinition (E:\Code\vulture\node_modules\graphql\language\parser.js:813:16)
    at parseTypeSystemDefinition (E:\Code\vulture\node_modules\graphql\language\parser.js:711:16)
    at parseDefinition (E:\Code\vulture\node_modules\graphql\language\parser.js:152:12)
    at many (E:\Code\vulture\node_modules\graphql\language\parser.js:1521:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vulture@1.0.0 start: `node index.js`
npm ERR! Exit status 1

I thought I did something wrong in the apollo-server side, but after reverting the changes the error was still there, so I decided to test it in the prisma admin. To my surprise, I couldn't save any posts, it would simply show 1 Unconfirmed change as you can see in the screenshot. Clicking on "Save to database" would do nothing at all.

image

So now I assume the problem is in the prisma side, but don't really know what's wrong.

To Reproduce Steps to reproduce the behavior:

  1. Update the prisma datamodel to
    
    type User {
    id: ID! @id
    username: String! @unique
    email: String! @unique
    password: String!
    name: String!
    posts: [Post!]!
    }

type Post { id: ID! @id title: String! author: User @relation(link: INLINE) }


2. Deploy and generate the client with `$ prisma deploy` and `$ prisma generate` respectively.
3. Go to http://localhost:4466/_admin and try to create a new post.
4. See error (nothing happens when saving to the database).

**Expected behavior**
When clicking on the Save to database button in the admin interface, I would expect it to save the data, currently, it does nothing. I can't even create new users. **Reverting the datamodel to the original one allows me to create users again**. 

**Screenshots**

![image](https://user-images.githubusercontent.com/11398826/56313845-330bd180-6119-11e9-9e84-ea01dffa8291.png)
![image](https://user-images.githubusercontent.com/11398826/56313863-3b640c80-6119-11e9-9bde-095cce22d350.png)

**Versions (please complete the following information):**
 - Connector: Postgres
 - Prisma Server: `1.31.0`
 - `prisma` CLI: `prisma/1.31.0`
 - OS: `Windows 10`
 - other dependencies: `prisma-client-lib 1.31.0`

**Additional context**
N/A.
pantharshit00 commented 5 years ago

@Oxyrus

I was unable to reproduce the issue. Can you please try clearing your localStorage to mitigate the prisma admin issue.

Also, if you can, please provide me with a small reproduction repository so that I can triage and fix the bug if it exists.

divyenduz commented 5 years ago

I think this is related to this https://github.com/prisma/prisma/issues/4424#issuecomment-486661094