How can I import graphql `type` from another graph...
# orm-help
s
How can I import graphql
type
from another graphql file using Prisma Client doesn’t work, But it does work with Prisma Binding ?
m
I also would like to import Types using prisma client. This is typically done like this # import Post from "./generated/prisma.graphql" But since prisma client generates the js file
./prisma-client/prisma-schema.js
, there must be a different way to accomplish an import of Types to schema.graphql
n
@Sh4reef @mikepuglisi could you please provide a bug report for this here: https://github.com/prisma/prisma?
m
Sure. Please clarify which part is the bug. 1) Prisma client is generating a
./prisma-client/prisma-schema.js
file when it should be generating a .graphql file OR 2) An error occurs when attempting to import types from the generated prisma-schema.js file? Example:
# import Post from "./prisma-client/prisma.graphql"
---- Note that everything else seems to be working fine with the `./prisma-client/prisma-schema.js, but I have to copy every single Type I'm using to schema.graphql manually. I'm pretty new to prisma, so I may be missing a fundamental concept.
n
to be able to answer 1) I would have to see your
prisma.yml
file, can you share it? 2) I don't understand this question, hence I asked for a bug report to get the full context.
m
My prisma.yml is now here https://github.com/mikepuglisi/prisma-client-example/blob/master/prisma/prisma.yml The prisma-client-example repo above was the result of following the 1.17 beta tutorial here: https://www.prisma.io/docs/get-started/01-setting-up-prisma-demo-server-a001/ Note that prisma generates a prisma-schema.js (as opposed to a generated/prisma.graphql) https://github.com/mikepuglisi/prisma-client-example/blob/master/prisma-client/prisma-schema.js So the question is: How can we import Types into schema.graphql now that there is no longer a prisma.graphql autogenerated from prisma? IOW, What is the equivilant of # import Post from "./generated/prisma.graphql" now that there is no prisma.graphql file?
n
You need to add the schema generator to your
prisma.yml
m
OK. I just spent 20 minutes searching the docs and web trying to figure out what you mean. Any pointer would be appreciated. I followed the current walk-through pretty explicitly https://www.prisma.io/docs/get-started/01-setting-up-prisma-demo-server-a001/
I found it... prisma.yml
Copy code
endpoint: <http://localhost:4466>
datamodel: datamodel.prisma

generate:
  - generator: javascript-client
    output: ../prisma-client/
  - generator: graphql-schema
    output: ../prisma-client/
s
It seems the bug has been fixed 🙂
Thanks guys