Skip to content

Commit d6a3f33

Browse files
committed
Add query for a specific flow and for all flows in a project
1 parent d7b5663 commit d6a3f33

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

app/graphql/types/query_type.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ module Types
44
class QueryType < Types::BaseObject
55
description 'Root Query type'
66

7+
field :flow, Types::FlowType, null: true, description: 'Fetches an flow given by its ID' do
8+
argument :id, ID, required: true, description: 'Id of the flow'
9+
end
10+
11+
field :flows, [Types::FlowType], null: true, description: 'Fetches all flows in a specific project' do
12+
argument :project_id, Types::GlobalIdType[::NamespaceProject], required: true, description: 'Id of the project'
13+
end
14+
715
field :node, Types::NodeType, null: true, description: 'Fetches an object given its ID' do
816
argument :id, ID, required: true, description: 'ID of the object'
917
end
@@ -42,6 +50,16 @@ class QueryType < Types::BaseObject
4250

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

53+
def flows(project_id:)
54+
organization = context.schema.object_from_id(project_id, context)
55+
56+
organization.flows
57+
end
58+
59+
def flow(id:)
60+
context.schema.object_from_id(id, context)
61+
end
62+
4563
def node(id:)
4664
context.schema.object_from_id(id, context)
4765
end

docs/graphql/object/query.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ Returns [`String!`](../scalar/string.md).
2626
|------|------|-------------|
2727
| `message` | [`String!`](../scalar/string.md) | String to echo as response |
2828

29+
### flow
30+
31+
Fetches an flow given by its ID
32+
33+
Returns [`Flow`](../object/flow.md).
34+
35+
| Name | Type | Description |
36+
|------|------|-------------|
37+
| `id` | [`ID!`](../scalar/id.md) | Id of the flow |
38+
39+
### flows
40+
41+
Fetches all flows in a specific project
42+
43+
Returns [`[Flow!]`](../object/flow.md).
44+
45+
| Name | Type | Description |
46+
|------|------|-------------|
47+
| `projectId` | [`NamespaceProjectID!`](../scalar/namespaceprojectid.md) | Id of the project |
48+
2949
### namespace
3050

3151
Find a namespace

spec/graphql/types/query_type_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
namespace
1616
node
1717
nodes
18+
flow
19+
flows
1820
]
1921
end
2022

0 commit comments

Comments
 (0)