From 043a95ec62597e83382d43587b9a7831ec88e7e8 Mon Sep 17 00:00:00 2001 From: Dario Pranjic Date: Thu, 4 Dec 2025 21:51:52 +0100 Subject: [PATCH 1/3] Fix some policies and graphql types --- app/graphql/sagittarius_schema.rb | 2 +- app/graphql/types/data_type_type.rb | 2 +- .../types/runtime_function_definition_type.rb | 4 ++-- .../types/runtime_parameter_definition_type.rb | 7 ++++++- app/graphql/types/runtime_type.rb | 3 +++ .../runtime_parameter_definition_policy.rb | 5 +++++ app/policies/runtime_policy.rb | 4 ++++ docs/graphql/object/runtime.md | 1 + docs/graphql/object/runtimefunctiondefinition.md | 2 +- .../object/runtimefunctiondefinitionconnection.md | 15 +++++++++++++++ .../object/runtimefunctiondefinitionedge.md | 13 +++++++++++++ docs/graphql/object/runtimeparameterdefinition.md | 1 + .../runtime_function_definition_type_spec.rb | 4 ++-- .../runtime_parameter_definition_type_spec.rb | 3 ++- spec/graphql/types/runtime_type_spec.rb | 1 + 15 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 app/policies/runtime_parameter_definition_policy.rb create mode 100644 docs/graphql/object/runtimefunctiondefinitionconnection.md create mode 100644 docs/graphql/object/runtimefunctiondefinitionedge.md diff --git a/app/graphql/sagittarius_schema.rb b/app/graphql/sagittarius_schema.rb index 63579065..a10b043f 100644 --- a/app/graphql/sagittarius_schema.rb +++ b/app/graphql/sagittarius_schema.rb @@ -5,7 +5,7 @@ class SagittariusSchema < GraphQL::Schema mutation(Types::MutationType) query(Types::QueryType) - default_max_page_size 50 + default_max_page_size 120 max_depth 20 connections.add(ActiveRecord::Relation, Sagittarius::Graphql::StableConnection) diff --git a/app/graphql/types/data_type_type.rb b/app/graphql/types/data_type_type.rb index 887d8442..62260d1d 100644 --- a/app/graphql/types/data_type_type.rb +++ b/app/graphql/types/data_type_type.rb @@ -4,7 +4,7 @@ module Types class DataTypeType < Types::BaseObject description 'Represents a DataType' - authorize :read_datatype + authorize :read_data_type field :aliases, Types::TranslationType.connection_type, null: true, description: 'Name of the function' field :display_messages, Types::TranslationType.connection_type, null: true, diff --git a/app/graphql/types/runtime_function_definition_type.rb b/app/graphql/types/runtime_function_definition_type.rb index 0b0d75cc..5942d130 100644 --- a/app/graphql/types/runtime_function_definition_type.rb +++ b/app/graphql/types/runtime_function_definition_type.rb @@ -4,7 +4,7 @@ module Types class RuntimeFunctionDefinitionType < Types::BaseObject description 'Represents a runtime function definition' - authorize :read_flow + authorize :read_runtime field :runtime, Types::RuntimeType, null: false, description: 'The runtime this runtime function definition belongs to' @@ -13,7 +13,7 @@ class RuntimeFunctionDefinitionType < Types::BaseObject null: true, description: 'Function definitions of the runtime function definition' - field :runtime_parameter_definitions, Types::RuntimeParameterDefinitionType.connection_type, + field :parameters, Types::RuntimeParameterDefinitionType.connection_type, null: true, description: 'Parameter definitions of the runtime function definition' diff --git a/app/graphql/types/runtime_parameter_definition_type.rb b/app/graphql/types/runtime_parameter_definition_type.rb index 05ecc659..d18076e6 100644 --- a/app/graphql/types/runtime_parameter_definition_type.rb +++ b/app/graphql/types/runtime_parameter_definition_type.rb @@ -4,7 +4,12 @@ module Types class RuntimeParameterDefinitionType < Types::BaseObject description 'Represents a runtime parameter definition' - authorize :read_flow + authorize :read_runtime + + field :identifier, String, + null: false, + description: 'Identifier of the runtime parameter definition', + method: :runtime_name id_field RuntimeParameterDefinition timestamps diff --git a/app/graphql/types/runtime_type.rb b/app/graphql/types/runtime_type.rb index 80c98162..22026e1b 100644 --- a/app/graphql/types/runtime_type.rb +++ b/app/graphql/types/runtime_type.rb @@ -13,6 +13,9 @@ class RuntimeType < Types::BaseObject field :namespace, Types::NamespaceType, null: true, description: 'The parent namespace for the runtime' field :projects, Types::NamespaceProjectType.connection_type, null: false, description: 'Projects associated with the runtime' + field :runtime_function_definitions, Types::RuntimeFunctionDefinitionType.connection_type, + null: false, + description: 'Functions of the runtime' field :status, Types::RuntimeStatusType, null: false, description: 'The status of the runtime' field :token, String, null: true, description: 'Token belonging to the runtime, only present on creation' diff --git a/app/policies/runtime_parameter_definition_policy.rb b/app/policies/runtime_parameter_definition_policy.rb new file mode 100644 index 00000000..1d4ed609 --- /dev/null +++ b/app/policies/runtime_parameter_definition_policy.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class RuntimeParameterDefinitionPolicy < BasePolicy + delegate { subject.runtime_function_definition } +end diff --git a/app/policies/runtime_policy.rb b/app/policies/runtime_policy.rb index 12bbd462..a6f86a59 100644 --- a/app/policies/runtime_policy.rb +++ b/app/policies/runtime_policy.rb @@ -2,4 +2,8 @@ class RuntimePolicy < BasePolicy delegate { subject.namespace || :global } + + rule { can?(:read_runtime) }.policy do + enable :read_data_type + end end diff --git a/docs/graphql/object/runtime.md b/docs/graphql/object/runtime.md index edee1f73..d9dee5e0 100644 --- a/docs/graphql/object/runtime.md +++ b/docs/graphql/object/runtime.md @@ -16,6 +16,7 @@ Represents a runtime | `name` | [`String!`](../scalar/string.md) | The name for the runtime | | `namespace` | [`Namespace`](../object/namespace.md) | The parent namespace for the runtime | | `projects` | [`NamespaceProjectConnection!`](../object/namespaceprojectconnection.md) | Projects associated with the runtime | +| `runtimeFunctionDefinitions` | [`RuntimeFunctionDefinitionConnection!`](../object/runtimefunctiondefinitionconnection.md) | Functions of the runtime | | `status` | [`RuntimeStatusType!`](../enum/runtimestatustype.md) | The status of the runtime | | `token` | [`String`](../scalar/string.md) | Token belonging to the runtime, only present on creation | | `updatedAt` | [`Time!`](../scalar/time.md) | Time when this Runtime was last updated | diff --git a/docs/graphql/object/runtimefunctiondefinition.md b/docs/graphql/object/runtimefunctiondefinition.md index aceb32b9..ad30c3a1 100644 --- a/docs/graphql/object/runtimefunctiondefinition.md +++ b/docs/graphql/object/runtimefunctiondefinition.md @@ -12,7 +12,7 @@ Represents a runtime function definition | `functionDefinitions` | [`FunctionDefinitionConnection`](../object/functiondefinitionconnection.md) | Function definitions of the runtime function definition | | `id` | [`RuntimeFunctionDefinitionID!`](../scalar/runtimefunctiondefinitionid.md) | Global ID of this RuntimeFunctionDefinition | | `identifier` | [`String!`](../scalar/string.md) | Identifier of the runtime function definition | +| `parameters` | [`RuntimeParameterDefinitionConnection`](../object/runtimeparameterdefinitionconnection.md) | Parameter definitions of the runtime function definition | | `runtime` | [`Runtime!`](../object/runtime.md) | The runtime this runtime function definition belongs to | -| `runtimeParameterDefinitions` | [`RuntimeParameterDefinitionConnection`](../object/runtimeparameterdefinitionconnection.md) | Parameter definitions of the runtime function definition | | `updatedAt` | [`Time!`](../scalar/time.md) | Time when this RuntimeFunctionDefinition was last updated | diff --git a/docs/graphql/object/runtimefunctiondefinitionconnection.md b/docs/graphql/object/runtimefunctiondefinitionconnection.md new file mode 100644 index 00000000..9de26754 --- /dev/null +++ b/docs/graphql/object/runtimefunctiondefinitionconnection.md @@ -0,0 +1,15 @@ +--- +title: RuntimeFunctionDefinitionConnection +--- + +The connection type for RuntimeFunctionDefinition. + +## Fields without arguments + +| Name | Type | Description | +|------|------|-------------| +| `count` | [`Int!`](../scalar/int.md) | Total count of collection. | +| `edges` | [`[RuntimeFunctionDefinitionEdge]`](../object/runtimefunctiondefinitionedge.md) | A list of edges. | +| `nodes` | [`[RuntimeFunctionDefinition]`](../object/runtimefunctiondefinition.md) | A list of nodes. | +| `pageInfo` | [`PageInfo!`](../object/pageinfo.md) | Information to aid in pagination. | + diff --git a/docs/graphql/object/runtimefunctiondefinitionedge.md b/docs/graphql/object/runtimefunctiondefinitionedge.md new file mode 100644 index 00000000..72b92fe7 --- /dev/null +++ b/docs/graphql/object/runtimefunctiondefinitionedge.md @@ -0,0 +1,13 @@ +--- +title: RuntimeFunctionDefinitionEdge +--- + +An edge in a connection. + +## Fields without arguments + +| Name | Type | Description | +|------|------|-------------| +| `cursor` | [`String!`](../scalar/string.md) | A cursor for use in pagination. | +| `node` | [`RuntimeFunctionDefinition`](../object/runtimefunctiondefinition.md) | The item at the end of the edge. | + diff --git a/docs/graphql/object/runtimeparameterdefinition.md b/docs/graphql/object/runtimeparameterdefinition.md index 5435fe13..8fb321d4 100644 --- a/docs/graphql/object/runtimeparameterdefinition.md +++ b/docs/graphql/object/runtimeparameterdefinition.md @@ -10,5 +10,6 @@ Represents a runtime parameter definition |------|------|-------------| | `createdAt` | [`Time!`](../scalar/time.md) | Time when this RuntimeParameterDefinition was created | | `id` | [`RuntimeParameterDefinitionID!`](../scalar/runtimeparameterdefinitionid.md) | Global ID of this RuntimeParameterDefinition | +| `identifier` | [`String!`](../scalar/string.md) | Identifier of the runtime parameter definition | | `updatedAt` | [`Time!`](../scalar/time.md) | Time when this RuntimeParameterDefinition was last updated | diff --git a/spec/graphql/types/runtime_function_definition_type_spec.rb b/spec/graphql/types/runtime_function_definition_type_spec.rb index ce3088a7..cd5c3123 100644 --- a/spec/graphql/types/runtime_function_definition_type_spec.rb +++ b/spec/graphql/types/runtime_function_definition_type_spec.rb @@ -8,7 +8,7 @@ id identifier functionDefinitions - runtimeParameterDefinitions + parameters runtime createdAt updatedAt @@ -17,5 +17,5 @@ it { expect(described_class.graphql_name).to eq('RuntimeFunctionDefinition') } it { expect(described_class).to have_graphql_fields(fields) } - it { expect(described_class).to require_graphql_authorizations(:read_flow) } + it { expect(described_class).to require_graphql_authorizations(:read_runtime) } end diff --git a/spec/graphql/types/runtime_parameter_definition_type_spec.rb b/spec/graphql/types/runtime_parameter_definition_type_spec.rb index b087e41a..4552317f 100644 --- a/spec/graphql/types/runtime_parameter_definition_type_spec.rb +++ b/spec/graphql/types/runtime_parameter_definition_type_spec.rb @@ -6,6 +6,7 @@ let(:fields) do %w[ id + identifier createdAt updatedAt ] @@ -13,5 +14,5 @@ it { expect(described_class.graphql_name).to eq('RuntimeParameterDefinition') } it { expect(described_class).to have_graphql_fields(fields) } - it { expect(described_class).to require_graphql_authorizations(:read_flow) } + it { expect(described_class).to require_graphql_authorizations(:read_runtime) } end diff --git a/spec/graphql/types/runtime_type_spec.rb b/spec/graphql/types/runtime_type_spec.rb index 094ad85f..a59b6d67 100644 --- a/spec/graphql/types/runtime_type_spec.rb +++ b/spec/graphql/types/runtime_type_spec.rb @@ -10,6 +10,7 @@ name dataTypes flowTypes + runtimeFunctionDefinitions description projects status From 375f7ad9e7d7c5efca9737913263aac4ccb5e5e0 Mon Sep 17 00:00:00 2001 From: Dario Pranjic <96529060+Knerio@users.noreply.github.com> Date: Fri, 5 Dec 2025 14:41:33 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Niklas van Schrick Signed-off-by: Dario Pranjic <96529060+Knerio@users.noreply.github.com> --- app/graphql/sagittarius_schema.rb | 2 +- app/graphql/types/runtime_function_definition_type.rb | 4 ++-- app/graphql/types/runtime_parameter_definition_type.rb | 2 +- app/policies/runtime_policy.rb | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/graphql/sagittarius_schema.rb b/app/graphql/sagittarius_schema.rb index a10b043f..63579065 100644 --- a/app/graphql/sagittarius_schema.rb +++ b/app/graphql/sagittarius_schema.rb @@ -5,7 +5,7 @@ class SagittariusSchema < GraphQL::Schema mutation(Types::MutationType) query(Types::QueryType) - default_max_page_size 120 + default_max_page_size 50 max_depth 20 connections.add(ActiveRecord::Relation, Sagittarius::Graphql::StableConnection) diff --git a/app/graphql/types/runtime_function_definition_type.rb b/app/graphql/types/runtime_function_definition_type.rb index 5942d130..3183963b 100644 --- a/app/graphql/types/runtime_function_definition_type.rb +++ b/app/graphql/types/runtime_function_definition_type.rb @@ -4,7 +4,7 @@ module Types class RuntimeFunctionDefinitionType < Types::BaseObject description 'Represents a runtime function definition' - authorize :read_runtime + authorize :read_runtime_function_definition field :runtime, Types::RuntimeType, null: false, description: 'The runtime this runtime function definition belongs to' @@ -13,7 +13,7 @@ class RuntimeFunctionDefinitionType < Types::BaseObject null: true, description: 'Function definitions of the runtime function definition' - field :parameters, Types::RuntimeParameterDefinitionType.connection_type, + field :runtime_parameter_definitions, Types::RuntimeParameterDefinitionType.connection_type, null: true, description: 'Parameter definitions of the runtime function definition' diff --git a/app/graphql/types/runtime_parameter_definition_type.rb b/app/graphql/types/runtime_parameter_definition_type.rb index d18076e6..bd7f6eb8 100644 --- a/app/graphql/types/runtime_parameter_definition_type.rb +++ b/app/graphql/types/runtime_parameter_definition_type.rb @@ -4,7 +4,7 @@ module Types class RuntimeParameterDefinitionType < Types::BaseObject description 'Represents a runtime parameter definition' - authorize :read_runtime + authorize :read_runtime_parameter_definition field :identifier, String, null: false, diff --git a/app/policies/runtime_policy.rb b/app/policies/runtime_policy.rb index a6f86a59..280a980a 100644 --- a/app/policies/runtime_policy.rb +++ b/app/policies/runtime_policy.rb @@ -5,5 +5,7 @@ class RuntimePolicy < BasePolicy rule { can?(:read_runtime) }.policy do enable :read_data_type + enable :read_runtime_function_definition + enable :read_runtime_parameter_definition end end From 42b724b92e1638af218da0db1197675f643ad116 Mon Sep 17 00:00:00 2001 From: Dario Pranjic Date: Fri, 5 Dec 2025 14:49:44 +0100 Subject: [PATCH 3/3] Fix some test --- docs/graphql/object/runtimefunctiondefinition.md | 2 +- spec/graphql/types/runtime_function_definition_type_spec.rb | 4 ++-- spec/graphql/types/runtime_parameter_definition_type_spec.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/graphql/object/runtimefunctiondefinition.md b/docs/graphql/object/runtimefunctiondefinition.md index ad30c3a1..aceb32b9 100644 --- a/docs/graphql/object/runtimefunctiondefinition.md +++ b/docs/graphql/object/runtimefunctiondefinition.md @@ -12,7 +12,7 @@ Represents a runtime function definition | `functionDefinitions` | [`FunctionDefinitionConnection`](../object/functiondefinitionconnection.md) | Function definitions of the runtime function definition | | `id` | [`RuntimeFunctionDefinitionID!`](../scalar/runtimefunctiondefinitionid.md) | Global ID of this RuntimeFunctionDefinition | | `identifier` | [`String!`](../scalar/string.md) | Identifier of the runtime function definition | -| `parameters` | [`RuntimeParameterDefinitionConnection`](../object/runtimeparameterdefinitionconnection.md) | Parameter definitions of the runtime function definition | | `runtime` | [`Runtime!`](../object/runtime.md) | The runtime this runtime function definition belongs to | +| `runtimeParameterDefinitions` | [`RuntimeParameterDefinitionConnection`](../object/runtimeparameterdefinitionconnection.md) | Parameter definitions of the runtime function definition | | `updatedAt` | [`Time!`](../scalar/time.md) | Time when this RuntimeFunctionDefinition was last updated | diff --git a/spec/graphql/types/runtime_function_definition_type_spec.rb b/spec/graphql/types/runtime_function_definition_type_spec.rb index cd5c3123..5769f8c0 100644 --- a/spec/graphql/types/runtime_function_definition_type_spec.rb +++ b/spec/graphql/types/runtime_function_definition_type_spec.rb @@ -8,7 +8,7 @@ id identifier functionDefinitions - parameters + runtimeParameterDefinitions runtime createdAt updatedAt @@ -17,5 +17,5 @@ it { expect(described_class.graphql_name).to eq('RuntimeFunctionDefinition') } it { expect(described_class).to have_graphql_fields(fields) } - it { expect(described_class).to require_graphql_authorizations(:read_runtime) } + it { expect(described_class).to require_graphql_authorizations(:read_runtime_function_definition) } end diff --git a/spec/graphql/types/runtime_parameter_definition_type_spec.rb b/spec/graphql/types/runtime_parameter_definition_type_spec.rb index 4552317f..a5f835a1 100644 --- a/spec/graphql/types/runtime_parameter_definition_type_spec.rb +++ b/spec/graphql/types/runtime_parameter_definition_type_spec.rb @@ -14,5 +14,5 @@ it { expect(described_class.graphql_name).to eq('RuntimeParameterDefinition') } it { expect(described_class).to have_graphql_fields(fields) } - it { expect(described_class).to require_graphql_authorizations(:read_runtime) } + it { expect(described_class).to require_graphql_authorizations(:read_runtime_parameter_definition) } end