Prisma1: Syntax Error: Expected Name, found }

Created on 27 Feb 2018  ยท  8Comments  ยท  Source: prisma/prisma1

Bug Report

Current behavior

type Breed {
  id: ID! @unique
  animals: [Animal!]! 
}

type Animal {
  id: ID! @unique
  name: String!
  breed: Breed!
}

If one of your type has a relation with another one that does not contain anything else than an id and relational fields, the prisma deploy command will end up with the error:

Syntax Error: Expected Name, found }

Prisma version:

$ prisma --version
prisma/1.2.8 (linux-x64) node-v8.7.0

Adding a dummy string-typed field fixes the issue:

type Breed {
  id: ID! @unique
  animals: [Animal!]! 
+ dummy: String
}
bu2-confirmed

Most helpful comment

When creating a datamodel that incudes types without scalar fields, a schema with empty input types is generated. This is a problem for graphql-js 0.11. graphql 0.12 & 0.13 can print this schema without problems. However, parsing the printed schema again results in this error.

Note that older versions of graphql-js throw a different error, described in #1817.

The fix here is that the backend should not generate empty input types. We're tackling that soon ๐Ÿ™‚

All 8 comments

Same in version Prisma 1.3.0

When creating a datamodel that incudes types without scalar fields, a schema with empty input types is generated. This is a problem for graphql-js 0.11. graphql 0.12 & 0.13 can print this schema without problems. However, parsing the printed schema again results in this error.

Note that older versions of graphql-js throw a different error, described in #1817.

The fix here is that the backend should not generate empty input types. We're tackling that soon ๐Ÿ™‚

This is now fixed and available in 1.4.0 ๐Ÿ™‚

I'm still having this issue on newly created projects, with prisma 1.4.1.

To replicate I created a new node-basic project with graphql-cli.
Adding this to database/datamodel.graphql and running yarn prisma deploy triggers the error:

type Root {
  value: TypeA
}

type TypeA {
  dummy: String
}

Still occurs on latest Prisma...
And workaround mentioned in first post does not work for me.

Prisma deploy - deploys code properly;
yarn start - results with "Syntax Error: Expected Name, found }" error

type Advice {
  id: ID! @unique
  name: String!
  value: Int!
  description: String!
  tags: [AdviceTag!]!
  categories: [AdviceCategory!]!
  dummy: String
}

type AdviceCategory {
  id: ID! @unique
  name: String!
  dummy: String
}

type AdviceTag {
  id: ID! @unique
  name: String!
  dummy: String
}
server git:(master) โœ— yarn start
yarn run v1.5.1
warning package.json: No license field
$ node src/index.js

/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:1299
  throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token));
  ^
GraphQLError: Syntax Error: Expected Name, found }
    at syntaxError (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/error/syntaxError.js:24:10)
    at expect (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:1299:32)
    at parseName (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:92:15)
    at parseFieldDefinition (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:809:14)
    at many (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:1348:16)
    at parseFieldsDefinition (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:799:50)
    at parseObjectTypeDefinition (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:757:16)
    at parseTypeSystemDefinition (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:663:16)
    at parseDefinition (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:143:16)
    at parseDocument (/Users/xxx/programowanie/xxx/test/hello-world/server/node_modules/graphql/language/parser.js:110:22)
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c node src/index.js

Hey @Evilweed, in the original issue, this error occured when running prisma deploy.

I just tried to deploy the data model you shared, and it worked without a problem. From what you shared with us so far, it's not clear what happens when you run yarn start.

Please create a new issue, including the information what happens when you run yarn start and a minimal reproduction. Thanks! ๐Ÿ™‚

@sergio91pt, I could reproduce the problem you describe.

Changing Root to this is a working work around:

type Root {
  id: ID! @unique
  value: TypeA
}

I cannot reproduce this on the latest version 1.6.3.
If you still run into a problem, please provide a full reproduction in a _new_ issue report ๐Ÿ™‚
Thanks ๐Ÿ™Œ

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikolasburk picture nikolasburk  ยท  3Comments

schickling picture schickling  ยท  3Comments

sorenbs picture sorenbs  ยท  3Comments

marktani picture marktani  ยท  3Comments

MitkoTschimev picture MitkoTschimev  ยท  3Comments