I'm currently using graphql-cli from Prisma to download the schema from endpoint. But, even after I deploy the changes I made to my schema, which gets deployed successfully, whenever I try to download the schema, I get project prisma - No changes
. And the generated prisma.graphql
is left unchanged.
I use the following command to download the schema:
graphql get-schema -p prisma --dotenv config/dev.env
dev.env
is simply to get PRISMA_ENDPOINT=http://localhost:4466/
environment variable.
I tried to generate prisma.graphql
in a different way by having the following in prisma.yml
:
endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
generate:
- generator: graphql-schema
output: ./generated/
And executed prisma generate
, but I get the error:
▸ [WARNING] in /Users/F/Documents/d/server/prisma/prisma.yml: A valid environment ▸ variable to satisfy the declaration 'env:PRISMA_ENDPOINT' could not be found.
Tried stopping and recreating Docker as well as deleting the node_module
and re-installing, but to no avail.
My package.json
:
{
"name": "graphql-basics",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node dist/index.js",
"heroku-postbuild": "babel src --out-dir dist --copy-files",
"dev": "env-cmd ./config/dev.env nodemon src/index.js --ext js,graphql --exec babel-node",
"test": "env-cmd ./config/test.env jest --watch --runInBand",
"get-schema": "graphql get-schema -p prisma --dotenv config/dev.env"
},
"jest": {
"globalSetup": "./tests/jest/globalSetup.js",
"globalTeardown": "./tests/jest/globalTeardown.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"@babel/polyfill": "^7.0.0",
"babel-cli": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
"bcryptjs": "^2.4.3",
"cross-fetch": "^2.2.2",
"env-cmd": "^8.0.2",
"google-auth-library": "^4.2.3",
"graphql-cli": "^3.0.14",
"graphql-yoga": "^1.14.10",
"jsonwebtoken": "^8.3.0",
"prisma-binding": "^2.1.1"
},
"devDependencies": {
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"jest": "^23.5.0",
"nodemon": "^1.17.5"
},
"resolutions": {
"graphql": "^14.5.8"
}
}
To fix the error "variable to satisfy the declaration 'env:PRISMA_ENDPOINT' could not be found." when calling prisma generate
you should either set the PRISMA_ENDPOINT
variable manually or load it via dotenv
. For example you could run npx dotenv -- prisma generate
to load the env vars from your .env file.
To download the schema from the endpoint via graphql get-schema
make sure to provide a properly configured .graphqlconfig.yml
and provide the correct project. A sample configuration for a prisma project could look like this:
projects:
prisma:
schemaPath: 'src/schema.graphql'
extensions:
endpoints:
default: 'http://localhost:4000/graphql'
database:
schemaPath: 'src/generated/prisma.graphql'
extensions:
prisma: 'database/prisma.yml'
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.