ash-project / ash-project/ash_graphql
Global graphql type definition
- Dominant language
- Elixir
- Stars
- 97
- Forks
- 101
- Avg merge
- 12h 51m
- Merged PRs (30d)
- 5
Description
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
### AI Policy
- [x] I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.
### Is your feature request related to a problem? Please describe.
I’m trying to create a DataLayer for ClickHouse and I find myself in a dilemma.
I could either define the functions `graphql_type/1` and `graphql_input_types/1` inside my type definition,
or avoid including anything related to GraphQL and let the user define that.
Currently, it’s possible to define `type` and `input_type` for each attribute of a resource,
but it can get a bit tedious if you have many tables and fields of the same type.
```elixir
extensions: [AshGraphql.Resource]
graphql do
type :my_clickhouse_resource
attribute_types [
ch_datetime64_column_1: :datetime,
ch_datetime64_column_2: :datetime
]
attribute_input_types [
ch_datetime64_column_1: :datetime,
ch_datetime64_column_2: :datetime
]
end
```
### Describe the solution you'd like
So I wanted to know if it would be possible to add a global configuration
that works for all attributes of that type.
Something like this:
```elixir
extensions: [AshGraphql.Domain]
graphql do
attribute_types [
{AshClickhouse.Type.ChDateTime64, :datetime}
]
attribute_input_types [
{AshClickhouse.Type.ChDateTime64, :datetime}
]
end
```
Or like this:
```elixir
config :ash_graphql,
attribute_types: [
{AshClickhouse.Type.ChDateTime64, :datetime}
],
attribute_input_types: [
{AshClickhouse.Type.ChDateTime64, :datetime}
]
```
I believe the ideal behavior would be for the configuration defined at the resource level
to override the global configuration.
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by tracing how the existing resource-level graphql attribute_types and attribute_input_types settings are read and applied. Determine where shared type mappings could be configured and how resource-level mappings should override them. Done means type-wide mappings work for both output and input types, with resource overrides covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir, graphql
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100