Describe the bug
When trying to run the application node index.js' you get this error message in the terminal:
GraphQLError: Syntax Error: Cannot parse the unexpected character ".".
To Reproduce
Steps to reproduce the behavior:
node index.js in the terminalExpected behavior
As I am following the Guide exactly step by step I would expect to have a running application after typing node index.js into the terminal.
Versions (please complete the following information):
prisma CLI: prisma/1.17.0-beta.11 (darwin-x64) node-v10.9.0graphql-yoga: 1.16.2Additional context
If you comment the field "typeDefs" in the last piece of code and you 'll see that the application runs
and if you uncomment it and try to run the application again you'll see the same error again.
The problem was that if you try to import Types into your datamodel.prisma the error that I described above is going to appear.
I've tried to import like so:
```# import Post from './datamodel.prisma'
I've noticed also another thing which caused an error that say's:
Couldn't find type unique in any of the schemas.
That's when you try to use directives like @unique in the schema.graphql.
You can't do that, you can only use the graphql directives in the datamodel.prisma file
I am going to close this issue now since I discovered the things that made troubles and now I've resolved them so I can continue my work.
Thanks for any help if you someone tried to research but couldn't find something.
And thanks to the one of the team members of prisma who put effort in helping me to find something
I am receiving this error when using # import * from './generated/prisma-client' to automatically expose my entire generated api for development. This used to work, then suddenly threw this error. I restarted the project because it was too big to troubleshoot, got it working fine, did some work on the client and came back to this error. I can't think of any edit I made since then. Minimum repo here github.com/jackgray/govtrackr
is there a different way to import generated api to the schema? If this is the best practice I'm curious how I get this error so easily now where as several versions ago never had an issue.
@jackgray I think I already helped you around this on slack.
@pantharshit00 kindly help as I'm facing the same issue.
I did # import * from './generated/prisma.grapql' but it seems the generated api is not imported to my working directory.
@seunzone
You will require to use graphql-import for this. It comes built-in with graphql-yoga but if you are using apollo server you will need to install it
After running prisma generate, a file prisma-schema.js was generated with all types of methods for me to use.
When trying to import that generated file into my schema.graphql file like this;
# import * from './generated/prisma-client/prisma-schema
I get the error;
GraphQLError: Syntax Error: Cannot parse the unexpected character ".".
It seems that the . from the path is causing this error, but its the only way to get to that file.
This issue was closed but it seems that a solution was never provided. Hopefully someone can help! Please let me know if I could provide more information to help solve this issue
@Solorio17 It seems you're trying to import a JavaScript file into graphql. That's not possible. Rather, the generated prisma client is for use in JS/TS. If you want to generate a schema, you have to define it in the prisma.yml. You can find more information here
@MathiasKandelborg Wow! I can't believe I didn't notice what I was trying to do. This was surely the problem! Thanks so much for the solution!
i have faced this issue and it happens because you have schema.graphql empty
happy hacking ;)
Most helpful comment
@Solorio17 It seems you're trying to import a JavaScript file into graphql. That's not possible. Rather, the generated prisma client is for use in JS/TS. If you want to generate a schema, you have to define it in the prisma.yml. You can find more information here