Skip to content

Add query for all flow types in a runtime #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/graphql/types/flow_type_setting_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Types
class FlowTypeSettingType < Types::BaseObject
description 'Represents a flow type setting'

authorize :read_flow_type_setting

field :data_type, Types::DataTypeType, null: true, description: 'Data type of the flow type setting'
field :descriptions, Types::TranslationType.connection_type, null: true,
description: 'Descriptions of the flow type setting'
field :flow_type, Types::FlowTypeType, null: true, description: 'Flow type of the flow type setting'
field :identifier, String, null: false, description: 'Identifier of the flow type setting'
field :names, Types::TranslationType.connection_type, null: true, description: 'Names of the flow type setting'
field :unique, Boolean, null: false, description: 'Unique status of the flow type setting'
end
end
19 changes: 19 additions & 0 deletions app/graphql/types/flow_type_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Types
class FlowTypeType < Types::BaseObject
description 'Represents a flow type'

authorize :read_flow_type

field :descriptions, Types::TranslationType.connection_type, null: true,
description: 'Descriptions of the flow type'
field :editable, Boolean, null: false, description: 'Editable status of the flow type'
field :flow_type_settings,
Types::FlowTypeSettingType.connection_type, null: true, description: 'Flow type settings of the flow type'
field :identifier, String, null: false, description: 'Identifier of the flow type'
field :input_type, Types::DataTypeType, null: true, description: 'Input type of the flow type'
field :names, Types::TranslationType.connection_type, null: true, description: 'Names of the flow type'
field :return_type, Types::DataTypeType, null: true, description: 'Return type of the flow type'
end
end
13 changes: 13 additions & 0 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class QueryType < Types::BaseObject

field :global_runtimes, Types::RuntimeType.connection_type, null: false, description: 'Find runtimes'

field :flow_types, Types::FlowTypeType.connection_type, null: false,
description: 'Find flow types in a specifc runtime' do
argument :runtime_id, Types::GlobalIdType[::Runtime], required: true,
description: 'GlobalID of the target runtime'
end

def node(id:)
context.schema.object_from_id(id, context)
end
Expand Down Expand Up @@ -76,6 +82,13 @@ def global_runtimes
Runtime.where(namespace: nil)
end

def flow_types(runtime_id:)
runtime = Runtime.find_by(id: runtime_id.model_id)
return [] unless runtime

FlowType.where(runtime: runtime)
end

def current_authentication
super.authentication
end
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/runtime_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class RuntimeType < Types::BaseObject

field :data_types, Types::DataTypeType.connection_type, null: false, description: 'DataTypes of the runtime'
field :description, String, null: false, description: 'The description for the runtime if present'
field :flow_types, Types::FlowTypeType.connection_type, null: false, description: 'FlowTypes of the runtime'
field :name, String, null: false, description: 'The name for the runtime'
field :namespace, Types::NamespaceType, null: true, description: 'The parent namespace for the runtime'
field :token, String, null: true, description: 'Token belonging to the runtime, only present on creation'
Expand Down
12 changes: 12 additions & 0 deletions app/graphql/types/translation_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Types
class TranslationType < Types::BaseObject
description 'Represents a translation'

authorize :read_translation

field :code, String, null: false, description: 'Code of the translation'
field :content, String, null: false, description: 'Content of the translation'
end
end
18 changes: 18 additions & 0 deletions docs/graphql/object/flowtype.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: FlowType
---

Represents a flow type

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `descriptions` | [`TranslationConnection`](../object/translationconnection.md) | Descriptions of the flow type |
| `editable` | [`Boolean!`](../scalar/boolean.md) | Editable status of the flow type |
| `flowTypeSettings` | [`FlowTypeSettingConnection`](../object/flowtypesettingconnection.md) | Flow type settings of the flow type |
| `identifier` | [`String!`](../scalar/string.md) | Identifier of the flow type |
| `inputType` | [`DataType`](../object/datatype.md) | Input type of the flow type |
| `names` | [`TranslationConnection`](../object/translationconnection.md) | Names of the flow type |
| `returnType` | [`DataType`](../object/datatype.md) | Return type of the flow type |

15 changes: 15 additions & 0 deletions docs/graphql/object/flowtypeconnection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: FlowTypeConnection
---

The connection type for FlowType.

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `count` | [`Int!`](../scalar/int.md) | Total count of collection. |
| `edges` | [`[FlowTypeEdge]`](../object/flowtypeedge.md) | A list of edges. |
| `nodes` | [`[FlowType]`](../object/flowtype.md) | A list of nodes. |
| `pageInfo` | [`PageInfo!`](../object/pageinfo.md) | Information to aid in pagination. |

13 changes: 13 additions & 0 deletions docs/graphql/object/flowtypeedge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: FlowTypeEdge
---

An edge in a connection.

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `cursor` | [`String!`](../scalar/string.md) | A cursor for use in pagination. |
| `node` | [`FlowType`](../object/flowtype.md) | The item at the end of the edge. |

17 changes: 17 additions & 0 deletions docs/graphql/object/flowtypesetting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: FlowTypeSetting
---

Represents a flow type setting

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `dataType` | [`DataType`](../object/datatype.md) | Data type of the flow type setting |
| `descriptions` | [`TranslationConnection`](../object/translationconnection.md) | Descriptions of the flow type setting |
| `flowType` | [`FlowType`](../object/flowtype.md) | Flow type of the flow type setting |
| `identifier` | [`String!`](../scalar/string.md) | Identifier of the flow type setting |
| `names` | [`TranslationConnection`](../object/translationconnection.md) | Names of the flow type setting |
| `unique` | [`Boolean!`](../scalar/boolean.md) | Unique status of the flow type setting |

15 changes: 15 additions & 0 deletions docs/graphql/object/flowtypesettingconnection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: FlowTypeSettingConnection
---

The connection type for FlowTypeSetting.

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `count` | [`Int!`](../scalar/int.md) | Total count of collection. |
| `edges` | [`[FlowTypeSettingEdge]`](../object/flowtypesettingedge.md) | A list of edges. |
| `nodes` | [`[FlowTypeSetting]`](../object/flowtypesetting.md) | A list of nodes. |
| `pageInfo` | [`PageInfo!`](../object/pageinfo.md) | Information to aid in pagination. |

13 changes: 13 additions & 0 deletions docs/graphql/object/flowtypesettingedge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: FlowTypeSettingEdge
---

An edge in a connection.

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `cursor` | [`String!`](../scalar/string.md) | A cursor for use in pagination. |
| `node` | [`FlowTypeSetting`](../object/flowtypesetting.md) | The item at the end of the edge. |

14 changes: 14 additions & 0 deletions docs/graphql/object/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ Returns [`String!`](../scalar/string.md).
|------|------|-------------|
| `message` | [`String!`](../scalar/string.md) | String to echo as response |

### flowTypes

Find flow types in a specifc runtime

Returns [`FlowTypeConnection!`](../object/flowtypeconnection.md).

| Name | Type | Description |
|------|------|-------------|
| `after` | [`String`](../scalar/string.md) | Returns the elements in the list that come after the specified cursor. |
| `before` | [`String`](../scalar/string.md) | Returns the elements in the list that come before the specified cursor. |
| `first` | [`Int`](../scalar/int.md) | Returns the first _n_ elements from the list. |
| `last` | [`Int`](../scalar/int.md) | Returns the last _n_ elements from the list. |
| `runtimeId` | [`RuntimeID!`](../scalar/runtimeid.md) | GlobalID of the target runtime |

### namespace

Find a namespace
Expand Down
1 change: 1 addition & 0 deletions docs/graphql/object/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Represents a runtime
| `createdAt` | [`Time!`](../scalar/time.md) | Time when this Runtime was created |
| `dataTypes` | [`DataTypeConnection!`](../object/datatypeconnection.md) | DataTypes of the runtime |
| `description` | [`String!`](../scalar/string.md) | The description for the runtime if present |
| `flowTypes` | [`FlowTypeConnection!`](../object/flowtypeconnection.md) | FlowTypes of the runtime |
| `id` | [`RuntimeID!`](../scalar/runtimeid.md) | Global ID of this Runtime |
| `name` | [`String!`](../scalar/string.md) | The name for the runtime |
| `namespace` | [`Namespace`](../object/namespace.md) | The parent namespace for the runtime |
Expand Down
13 changes: 13 additions & 0 deletions docs/graphql/object/translation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Translation
---

Represents a translation

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `code` | [`String!`](../scalar/string.md) | Code of the translation |
| `content` | [`String!`](../scalar/string.md) | Content of the translation |

15 changes: 15 additions & 0 deletions docs/graphql/object/translationconnection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: TranslationConnection
---

The connection type for Translation.

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `count` | [`Int!`](../scalar/int.md) | Total count of collection. |
| `edges` | [`[TranslationEdge]`](../object/translationedge.md) | A list of edges. |
| `nodes` | [`[Translation]`](../object/translation.md) | A list of nodes. |
| `pageInfo` | [`PageInfo!`](../object/pageinfo.md) | Information to aid in pagination. |

13 changes: 13 additions & 0 deletions docs/graphql/object/translationedge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: TranslationEdge
---

An edge in a connection.

## Fields without arguments

| Name | Type | Description |
|------|------|-------------|
| `cursor` | [`String!`](../scalar/string.md) | A cursor for use in pagination. |
| `node` | [`Translation`](../object/translation.md) | The item at the end of the edge. |

20 changes: 20 additions & 0 deletions spec/graphql/types/flow_type_setting_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe SagittariusSchema.types['FlowTypeSetting'] do
let(:fields) do
%w[
identifier
unique
flow_type
data_type
names
descriptions
]
end

it { expect(described_class.graphql_name).to eq('FlowTypeSetting') }
it { expect(described_class).to have_graphql_fields(fields) }
it { expect(described_class).to require_graphql_authorizations(:read_flow_type_setting) }
end
21 changes: 21 additions & 0 deletions spec/graphql/types/flow_type_type_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe SagittariusSchema.types['FlowType'] do
let(:fields) do
%w[
identifier
editable
input_type
return_type
flow_type_settings
names
descriptions
]
end

it { expect(described_class.graphql_name).to eq('FlowType') }
it { expect(described_class).to have_graphql_fields(fields) }
it { expect(described_class).to require_graphql_authorizations(:read_flow_type) }
end
1 change: 1 addition & 0 deletions spec/graphql/types/query_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace
node
nodes
flow_types
]
end

Expand Down
1 change: 1 addition & 0 deletions spec/graphql/types/runtime_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace
name
dataTypes
flowTypes
description
token
createdAt
Expand Down
16 changes: 16 additions & 0 deletions spec/graphql/types/translation_type_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe SagittariusSchema.types['Translation'] do
let(:fields) do
%w[
code
content
]
end

it { expect(described_class.graphql_name).to eq('Translation') }
it { expect(described_class).to have_graphql_fields(fields) }
it { expect(described_class).to require_graphql_authorizations(:read_translation) }
end