Skip to content

Opinionated generators for Phoenix/Absinthe apps

Notifications You must be signed in to change notification settings

kidqueb/ash-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ash

Set of opinionated generators for Phoenix & Absinthe. Creates contexts with dataloader and a authorization policy as well as resolver, types and tests for graphql resources.

Takes similar arguments to mix phx.gen.context and creates a graphgql resource. Untested on anything other than simple types lieke strings, integers and booleans.

Mix Ash Context & Schema

Borrowed from the Phoenix generators where they pass objects that contain necessary info to generate files. These are examples of the objects. Will move this out after I stop referencing it so much ha

%Mix.Ash.Context{
  alias: Blog,
  base_module: Ash,
  basename: "blog",
  context_app: :ash,
  dir: "lib/ash/blog",
  file: "lib/ash/blog.ex",
  generate?: true,
  module: Ash.Blog,
  name: "Blog",
  opts: [],
  schema: %Mix.Ash.Schema{
    alias: Post,
    assocs: [],
    attrs: [title: :string, word_count: :integer, is_draft: :boolean],
    binary_id: nil,
    context_app: :ash,
    defaults: %{},
    embedded?: false,
    file: "lib/ash/blog/post.ex",
    generate?: true,
    human_plural: "Posts",
    human_singular: "Post",
    indexes: [],
    migration?: true,
    migration_defaults: %{},
    migration_module: Ecto.Migration,
    module: Ash.Blog.Post,
    opts: [],
    params: %{create: %{}, default_key: :some_field, update: %{}},
    plural: "posts",
    repo: Ash.Repo,
    route_helper: "post",
    sample_id: -1,
    singular: "post",
    string_attr: nil,
    table: "posts",
    types: %{},
    uniques: [],
    web_namespace: nil,
    web_path: nil
  },
  test_file: "test/ash/blog_test.exs",
  web_module: AshWeb
}

%Mix.Ash.Schema{
  alias: Post,
  assocs: [],
  attrs: [],
  binary_id: nil,
  context_app: :ash,
  defaults: %{},
  embedded?: false,
  file: "lib/ash/blog/post.ex",
  generate?: true,
  human_plural: "Posts",
  human_singular: "Post",
  indexes: [],
  migration?: true,
  migration_defaults: %{},
  migration_module: Ecto.Migration,
  module: Ash.Blog.Post,
  opts: [],
  params: %{create: %{}, default_key: :some_field, update: %{}},
  plural: "posts",
  repo: Ash.Repo,
  route_helper: "post",
  sample_id: -1,
  singular: "post",
  string_attr: nil,
  table: "posts",
  types: %{},
  uniques: [],
  web_namespace: nil,
  web_path: nil
}

About

Opinionated generators for Phoenix/Absinthe apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages