ash/documentation/topics/contexts_and_domains.md

15 lines
1.1 KiB
Markdown
Raw Normal View History

2020-08-23 10:44:05 +12:00
# Contexts and Domains
2021-04-11 09:36:40 +12:00
It is suggested that you read a bit on Domain Driven Design before proceeding. If you are using phoenix or are familiar with phoenix contexts, then this will make sense to you.
2020-08-23 10:44:05 +12:00
In order to support domain driven design, Ash supports defining multiple APIs, each with their own set of resources. It is possible to share a resource between APIs, but this gets untenable very quickly because any resources related to the shared resource must _both_ appear in each API.
An experimental "Delegation" data layer was added to allow you to use other resources in other APIs as the data layer for a resource, but it created a significant amount of complexity in determining data layer behavior. Instead, simply use the same data layer and configuration in both resources.
2020-08-23 10:44:05 +12:00
Things missing to make this work well:
2020-08-23 10:44:05 +12:00
- Define the ecto schema as a separate module (prerequisite for hidden attributes)
- "hidden" attributes - attributes that are defined on the schema but not the Ash struct
- ability to filter on hidden fields in certain places (haven't determined where this needs to happen)
- ability to add a "base_filter" that can leverage hidden attributes