From a8782a7f91afd57b7d5c945e4782a88cd015ec72 Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Thu, 22 Sep 2022 13:44:04 -0400 Subject: [PATCH] Add display name for stacks (#557) will help us use better prosaic names for stacks where needed --- apps/core/lib/core/schema/stack.ex | 13 +++++---- .../20220922155143_add_stack_display_name.exs | 9 ++++++ apps/graphql/lib/graphql/schema/recipe.ex | 28 ++++++++++--------- 3 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 apps/core/priv/repo/migrations/20220922155143_add_stack_display_name.exs diff --git a/apps/core/lib/core/schema/stack.ex b/apps/core/lib/core/schema/stack.ex index 2719be8d1..45b96b38a 100644 --- a/apps/core/lib/core/schema/stack.ex +++ b/apps/core/lib/core/schema/stack.ex @@ -3,11 +3,12 @@ defmodule Core.Schema.Stack do alias Core.Schema.{Account, User, StackCollection, Repository} schema "stacks" do - field :name, :string - field :description, :string - field :featured, :boolean, default: :false - field :bundles, :map, virtual: true - field :expires_at, :utc_datetime_usec + field :name, :string + field :description, :string + field :featured, :boolean, default: :false + field :display_name, :string + field :bundles, :map, virtual: true + field :expires_at, :utc_datetime_usec belongs_to :account, Account belongs_to :creator, User @@ -33,7 +34,7 @@ defmodule Core.Schema.Stack do from(s in query, order_by: ^order) end - @valid ~w(name description featured expires_at)a + @valid ~w(name description featured expires_at display_name)a def changeset(model, attrs \\ %{}) do model diff --git a/apps/core/priv/repo/migrations/20220922155143_add_stack_display_name.exs b/apps/core/priv/repo/migrations/20220922155143_add_stack_display_name.exs new file mode 100644 index 000000000..1454a42df --- /dev/null +++ b/apps/core/priv/repo/migrations/20220922155143_add_stack_display_name.exs @@ -0,0 +1,9 @@ +defmodule Core.Repo.Migrations.AddStackDisplayName do + use Ecto.Migration + + def change do + alter table(:stacks) do + add :display_name, :string + end + end +end diff --git a/apps/graphql/lib/graphql/schema/recipe.ex b/apps/graphql/lib/graphql/schema/recipe.ex index fbb73452b..9c01a32e7 100644 --- a/apps/graphql/lib/graphql/schema/recipe.ex +++ b/apps/graphql/lib/graphql/schema/recipe.ex @@ -24,11 +24,12 @@ defmodule GraphQl.Schema.Recipe do end input_object :stack_attributes do - field :name, non_null(:string) - field :description, :string - field :featured, :boolean - field :collections, list_of(:stack_collection_attributes) - field :community, :community_attributes + field :name, non_null(:string) + field :description, :string + field :featured, :boolean + field :display_name, :string + field :collections, list_of(:stack_collection_attributes) + field :community, :community_attributes end input_object :stack_collection_attributes do @@ -199,14 +200,15 @@ defmodule GraphQl.Schema.Recipe do end object :stack do - field :id, non_null(:id) - field :name, non_null(:string) - field :description, :string - field :featured, :boolean - field :community, :community - field :collections, list_of(:stack_collection), resolve: dataloader(Recipe) - field :creator, :user, resolve: dataloader(User) - field :bundles, list_of(:recipe) + field :id, non_null(:id) + field :name, non_null(:string) + field :description, :string + field :featured, :boolean + field :community, :community + field :display_name, :string + field :collections, list_of(:stack_collection), resolve: dataloader(Recipe) + field :creator, :user, resolve: dataloader(User) + field :bundles, list_of(:recipe) timestamps() end