Skip to content

Global graphql type definition #357

@JVMartyns

Description

@JVMartyns

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • 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.

  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:

  extensions: [AshGraphql.Domain]

  graphql do
    attribute_types [
      {AshClickhouse.Type.ChDateTime64, :datetime}
    ]
    
    attribute_input_types [
      {AshClickhouse.Type.ChDateTime64, :datetime}
    ]
  end

Or like this:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions