pal generate

Alias: pal g

Use this command to scaffold all the boring code into your project.

Can generate queries, mutations, admin pages, apollo client queries and mutations documents

> pal generate [MODELS] [TYPE]

MODELSnoschema model name to generate files for. You can pass one or more models like User,Post
TYPEno(crud|queries|mutations|admin|graphql) Type of files to generate you can send one or more like queries,mutations


-c--config=config[default: pal] You can pass custom config file name
-h--helpshow CLI help

Here's the matrix of which files are generated by which command:

TypeMutationsQueriesClient GraphQLAdmin pages


  # To generate everything for all models in your schema
  > pal g

  Note: you need to change User,Post with your schema models

  # To generate everything for model or more
  > pal g User,Post

  # To generate queries for one model or more
  > pal g User,Post queries

  # To generate mutations for one model or more
  > pal g User,Post mutations

  # To generate admin for one model or more
  > pal g User,Post admin

  # To generate graphql for one model or more
  > pal g User,Post graphql

  # To generate queries and mutations for one model or more
  > pal g User,Post crud


Generated code depending on the type of generator

Config file

To customize the generator with your needs and project dirs you need to create configurations.

Add new file to your project root path with name pal.js or pal.json

You can change file name and pass it to your command

> pal g -c=config

type definitions for config file

interface Config {
  // add backend generator
  backend?: {    // generator type it's require
    generator: GeneratorsType;    // if you have our admin PrismaTable and need to customize his settings schema path default prisma/
    adminSettingsPath?: string;  } & Options;
  // add frontend generator
  frontend?: {    // generate admin settings and pages
    admin?: AdminPagesOptions | boolean;    // generate graphql client documents
    graphql?: Options | boolean;  };
type GeneratorsType = 'nexus' | 'sdl' | 'graphql-modules' | 'nexus-plugin-prisma';