Prisma1: "Syntax Error: Expected Name, found }" when deploying a type without scalar fields

Created on 20 Mar 2018  Â·  12Comments  Â·  Source: prisma/prisma1

Bug Report

Current behavior

When including a type (as a to-one relation) that only has an id field (or an id field and a relation), I get an error on prisma deploy:

Hooks:

Checking, if schema file changed...  client introspecting transform-server dev +509ms
 !
Syntax Error: Expected Name, found }

GraphQL request (1001:1)
1000: 
1001: }
      ^
1002: 

    at syntaxError (/usr/local/lib/node_modules/prisma/node_modules/graphql/error/syntaxError.js:24:10)
    at expect (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:1299:32)
    at parseName (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:92:15)
    at parseInputValueDef (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:842:14)
    at many (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:1348:16)
    at parseInputFieldsDefinition (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:992:50)
    at parseInputObjectTypeDefinition (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:977:16)
    at parseTypeSystemDefinition (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:671:16)
    at parseDefinition (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:143:16)
    at parseDocument (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:110:22)
    at Object.parse (/usr/local/lib/node_modules/prisma/node_modules/graphql/language/parser.js:38:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/src/commands/deploy/printSchema.ts:30:20)
    at step (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/printSchema.js:32:23)
    at Object.next (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/printSchema.js:13:53)
    at fulfilled (/usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core/dist/commands/deploy/printSchema.js:4:58)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
Exiting with code: 1
Davids-MacBook-Pro-2:transform-server davidyoung$ 

Reproduction

Types:

type Plan {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!

  title: String!

  description: String

  # Set if this plan is an adjustment from a previous plan
  previousPlan: Plan
  nutritionDays: NutritionDays!
}

type NutritionDays {
  id: ID! @unique

  plan: Plan!
}

If I add a: Int to the NutritionDays type, it deploys without an issue.

Expected behavior?

Not needing to add a Scalar type to deploy without an error.

bu2-confirmed aredeploy areengine statustale

All 12 comments

I can confirm this issue.

We had to give a String field to a type with just a relation to make it deploy.

Same issue, but I found that adding id to TweetPath was enough to remove the error.

type User {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  handle: String! @unique
  email: String! @unique
  name: String
  description: String
  website: String
  themeColor: String! @default(value: "#1da1f2")
  location: Location
  birthday: DateTime
  coverPhoto: Asset @relation(name: "UserCoverPhoto", onDelete: CASCADE)
  profilePicture: Asset @relation(name: "UserProfilePicture", onDelete: CASCADE)
  tweets: [Tweet!]! @relation(name: "UserTweets", onDelete: CASCADE)
  includedIn: [Tweet!]! @relation(name: "UserTweetsIncluded")
  retweets: [Retweet!]! @relation(name: "UserRetweets", onDelete: CASCADE)
  likes: [TweetLike!]! @relation(name: "UserLikes", onDelete: CASCADE)
  follows: [User!]! @relation(name: "UserFollows")
  followedBy: [User!]! @relation(name: "UserFollows")
  passwordHash: String!
}

type Location {
  latitude: Float!
  longitude: Float!
}

type Tweet {
  id: ID! @unique
  createdAt: DateTime!
  text: String!
  owner: User! @relation(name: "UserTweets")
  includes: [User!]! @relation(name: "UserTweetsIncluded")
  assets: [Asset!]!
  location: Location
  ancestorPath: TweetPath! @relation(name: "TweetPathAncestor")
  descendantPath: TweetPath! @relation(name: "TweetPathDescendant")
  retweets: [Retweet!]! @relation(name: "TweetRetweets", onDelete: CASCADE)
  like: [TweetLike!]! @relation(name: "TweetLikes", onDelete: CASCADE)
}

type TweetPath {
  id: ID! @unique
  ancestor: Tweet @relation(name: "TweetPathAncestor")
  descendant: Tweet @relation(name: "TweetPathDescendant")
}

type Retweet {
  createdAt: DateTime!
  retweeted: Tweet! @relation(name: "TweetRetweets")
  by: User! @relation(name: "UserRetweets")
}

type TweetLike {
  createdAt: DateTime!
  liked: Tweet! @relation(name: "TweetLikes")
  by: User! @relation(name: "UserLikes")
}

type Asset {
  publicId: String! @unique
  createdAt: DateTime!
  coverPhotoOf: User @relation(name: "UserCoverPhoto")
  profilePictureOf: User @relation(name: "UserProfilePicture")
}

Thanks for reporting everyone and sorry for the late response! I'm trying to reproduce this with [email protected], but can't. Which version of the prisma cli are you using?

I also cannot reproduce this, but could before.

on version prisma/1.6.0
types with only relations can deploy now.
Cannot reproduce anymore.

Thanks for the confirmation, I'll close this issue.

I encountered this error on prisma/1.6.3 (darwin-x64) node-v9.6.1.
The part of the schema is question was:

type Customer {
  id: ID! @unique
  fields: [FieldValue!]!
}

type Value {
  TEXT: String
  LONGTEXT: String
  NUMBER: Integer
  CURRENCY: Float
  SELECT: String
  DATE: DateTime
  YESNO: Boolean
}

type FieldValue {
  id: ID! @unique // omitting this field 
  field: Field!
  value: Value!
}

If I omit the above marked field (id on FieldValue), I get the error:

Checking, if schema file changed !
 â–¸    Syntax Error: Expected Name, found }

This is not an issue for me currently as I needed to add this field (id) but wanted to report since I encountered this issue, though since it's been closed.

Prisma is awesome, keep up the great work! 😄

Hey @isaiahgrey93, can you additionally share the Field type/enum?

Yep, I got this error too.

To me the problem was that since I didn't have any scalar values on the type, the generated "PreviousValues" query of the type was empty in the prisma.graphql file, giving the error.

Syntax Error: Expected Name, found }

Noticed it by enabling the verbose output (getting the line number within prisma.graphql)

It was just a simple bug with Graphql-cli
https://github.com/graphql-cli/graphql-cli/issues/284

Delete all your generated files and it'll work fine.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I believe this to be fixed due to #2623. Please open a _new_ issue if you encounter this still.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoodsy picture hoodsy  Â·  3Comments

nikolasburk picture nikolasburk  Â·  3Comments

marktani picture marktani  Â·  3Comments

notrab picture notrab  Â·  3Comments

akoenig picture akoenig  Â·  3Comments