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
}
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 ๐
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-jsthrow a different error, described in #1817.The fix here is that the backend should not generate empty input types. We're tackling that soon ๐