Ash FrameworkAF
Ash Framework3y ago
18 replies
moxley

AshGraphql Manage Relationships with multiple actions

Hello, I'm using the AshGraphql managed_relationships DSL to allow a GraphQL mutation to update relationship data on a resource. I works fine with the :create action, but on adding the similar code for the :update action, it gives errors. Here are the relevant parts of the resource module:


defmodule GF.WebSite do
actions do
  # Add a set of simple actions. You'll customize these later.
  defaults [:read, :destroy]

  create :create do
    argument :components, {:array, :map}
    change manage_relationship(:components, type: :direct_control)
  end

  create :update do
    argument :components, {:array, :map}
    change manage_relationship(:components, type: :direct_control)
  end
end

graphql do
  type :web_site

  mutations do
    create :create_web_site, :create
    update :update_web_site, :update
  end

  managed_relationships do
    managed_relationship :create, :components
    managed_relationship :update, :components
  end
end


With the code above, there is a compiler error, Type name "CreateWebSiteComponentsInput" is not unique.. What do I need to change to make this work?

I read the documentation about Graphql managed relationships. It's not all clicking yet for me.
https://ash-hq.org/docs/dsl/ash-resource#graphql-managed_relationships
Ash HQ
View the documentation for Ash.Resource on Ash HQ.
Ash.Resource
Was this page helpful?