docs/1.8/04-Reference/08-Prisma-Bindings/03-Code-generation.md
prisma-binding comes with a built-in generator CLI you can use to generate your binding.
Install with npm:
npm install -g prisma-binding
Install with yarn:
yarn global add prisma-binding
Usage: prisma-binding -i [input] -l [language] -b [outputBinding]
Options:
--help Show help [boolean]
--version Show version number [boolean]
--input, -i Path to prisma.graphql file [string] [required]
--language, -l Language of the generator. Available languages:
typescript, javascript [string] [required]
--outputBinding, -b Output binding. Example: binding.ts [string] [required]
The prisma-binding CLI integrates with GraphQL Config. This means instead of passing arguments to the command, you can write a .graphqlconfig.yml file which will be read by the CLI.
For example, consider the following .graphqlconfig.yml:
projects:
myapp:
schemaPath: src/generated/prisma.graphql
extensions:
prisma: prisma/prisma.yml
codegen:
- generator: prisma-binding
language: typescript
output:
binding: src/generated/prisma.ts
Invoking simply graphql codegen in a directory where the above .graphqlconfig is available is equivalent to invoking the following terminal command:
prisma-binding \
--language typescript \
--outputBinding src/generated/prisma.ts
prisma-binding v1.XVersions lower than 2.0 of prisma-binding were based on the graphql prepare instead of the graphql codegen command. Here is how you need to update your Prisma project files to account for the changes:
prisma.yml
# ... other properties
hooks:
post-deploy:
- graphql get-schema
- graphql codegen
.graphqlconfig.yml
projects:
myapp:
schemaPath: src/generated/prisma.graphql
extensions:
prisma: prisma/prisma.yml
codegen:
- generator: prisma-binding
language: typescript
output:
binding: src/generated/prisma.ts