Skip to content

Prisma generator to generate files for Elixir programs (Ecto and Absinthe)

License

Notifications You must be signed in to change notification settings

raarts/prisma-generator-elixir

Repository files navigation

Prisma Generator Elixir (Stalled)

  1. What is it?
  2. Usage
  3. Example
  4. License

This is absolutely not ready yet, pre-alpha, and I parked it, because I switched to Hasura on the server for the moment. It does generate usable code though, feel free to fork/copy.

What is it?

Generates schema, resolvers, for models in your Prisma Schema.

Usage

npm install --save-dev @raarts/prisma-generator-elixir
generator elixir {
  provider                        = "prisma-generator-elixir"
  output                          = "../hello/lib/hello_web"
  appname                         = "Hallo"
}

Parameters

  • [output]: (required) - output path relative to your schema.prisma file
  • [appname]: (required) - Base name of the Elixir Application
  • [genEcto]: (optional) - Generate Ecto schema. Default true
  • [genTypes]: (optional) - Generate Absinthe Type files. Default true
  • [genResolvers]: (optional) - Generate Absinthe Resolvers based on Ecto Repo calls. Default true
  • [genSchema]: (optional) - Generate Absinthe Schema file. Default true
  • [genMigration]: (optional) - Generate Ecto migration file. Default false

Example

Prisma Schema
generator elixirAbsinthe {
provider = "prisma-generator-elixir"
output = "../src"
}

model Question {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
/// @DtoReadOnly
createdAt DateTime @default(now())
/// @DtoRelationRequired
createdBy User? @relation("CreatedQuestions", fields: [createdById], references: [id])
createdById String? @db.Uuid
updatedAt DateTime @updatedAt
/// @DtoRelationRequired
updatedBy User? @relation("UpdatedQuestions", fields: [updatedById], references: [id])
updatedById String? @db.Uuid

  /// @DtoRelationRequired
  /// @DtoRelationCanConnectOnCreate
  category   Category? @relation(fields: [categoryId], references: [id])
  categoryId String?   @db.Uuid

  /// @DtoCreateOptional
  /// @DtoRelationCanCreateOnCreate
  /// @DtoRelationCanConnectOnCreate
  /// @DtoRelationCanCreateOnUpdate
  /// @DtoRelationCanConnectOnUpdate
  tags Tag[]

  title     String
  content   String
  responses Response[]

}
Generated results

License

All files are released under the Apache License 2.0.

About

Prisma generator to generate files for Elixir programs (Ecto and Absinthe)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published