I'm creating a back-end using the Prisma-cli, which automatically creates the datamodel.prisma file. From looking at Prisma's official examples[1], it seems like they all have a schema.graphql file as well. Anyone know if there's a way to generate a schema.graphql file from a datamodel.prisma file (and then just fill in the Mutation and Query types)?
It just seems repetitive if you had to manually create and maintain both files since they're very similar.
[1] https://github.com/prisma/prisma-examples/tree/master/typescript
Hmm seems this isn't possible, but what I really like of this (have separated files) is that from schema.graphql
you can define wich should be accesible for the client.
For example if you have User model, you can overwrite it to hide password or things like that.
What I already do in my schema.graphql
is import the entire generated prisma.schema
: # import * from "./generated/prisma.graphql"
Regards
Checkout here - Create a.graphqlconfig file in the root of your project. Paste the below config And also create src/generated folder. Run the cmd after installing CLI: graphql get-schema -p prisma.
{
"projects": {
"prisma": {
"schemaPath": "src/generated/prisma.graphql",
"extensions": {
"endpoints": {
"default": "http://localhost:4466"
}
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.