question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to configure custom schema location instead of requiring `--schema` arg

See original GitHub issue

Problem

For people who use a custom schema location, the current DX is super painful. All of the CLI commands fail unless you explicitly pass --schema. When you are using the cli a lot in a project with a custom schema, this gets super annoying having to type --schema all the time.

Additionally, using a custom schema means the prisma postinstall hook fails, requiring projects to add their own postinstall hook to manually generate the client.

And then also of course we use a custom schema location in Blitz and abstract most of the prisma CLI commands. But when a user needs to drop down a level and use the prisma cli directly, they often get stuck because they don’t know they need to provide --schema

Suggested solution

I want to be able to define prisma config in the package.json file. Something like this:

{
  "scripts": {},
  "prisma": {
    "schema": "db/schema.prisma"
  },
  "dependencies": {}
}

Alternatives

An alternative is to add a config file at the repo root, like .prisma.config.js or something.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:34
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

8reactions
matthewmuellercommented, Aug 17, 2020

To keep this moving, I’d suggest we add support for package.json. It seems like there’s quite a bit of people want it and I don’t see any harm in supporting it.

"prisma": {
  "schema": "db/schema.prisma"
}

Later on, when we have imports, this solution can be our go-to for Go.

4reactions
janpiocommented, Sep 15, 2020

Some technical details for the implementation after discussion with @timsuchanek and @Jolg42:

  • Right now we 1) use --schema or 2) fall back to ./prisma/schema.prisma (or ./schema.prisma) to find the schema file to load.
  • The idea is to in between 1) and 2) add a new step where we look at the location that is defined in the package.json file as defined in https://github.com/prisma/prisma/issues/3144#issuecomment-674820240.
    • That means that even if you have a path defined in your package.json, you can manually override that by using --schema in the CLI command.
  • Additionally the output the CLI gives you where it loaded the .env file from (which is next to the schema file) should also mention the schema.prisma file to make that explicit.

Details about documentation of this feature are still figured out, as the schema loading is currently not documented at all directly.

Previous, slightly related documentation:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating schema directives - Apollo GraphQL Docs
Supported locations. Your custom directive can appear only in the schema locations you list after the on keyword in the directive's definition.
Read more >
Active Directory: Schema Update and Custom Attribute
Step 1: Login to Schema Master Domain Controller, with Schema Admin ... Rather than directly adding a custom attribute in the existing class ......
Read more >
Schema export directory is not provided to the annotation ...
I've configured everything, but when I compile, Android Studio gives me this warning: Schema export directory is not provided to the annotation ...
Read more >
Prisma schema (Reference)
You can also use environment variables inside the schema file to provide configuration options when a CLI command is invoked. Example. The following...
Read more >
Schema Factory Definition in SolrConfig - Apache Solr
An alternative to using a managed schema is to explicitly configure a ClassicIndexSchemaFactory . ClassicIndexSchemaFactory requires the use of a schema.xml ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found