Skip to content

Commit 124f7f6

Browse files
committed
Move flow queries into namespace_project_type.rb instead of query_type
1 parent d6a3f33 commit 124f7f6

File tree

8 files changed

+62
-41
lines changed

8 files changed

+62
-41
lines changed

app/graphql/types/namespace_project_type.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,35 @@ module Types
44
class NamespaceProjectType < Types::BaseObject
55
description 'Represents a namespace project'
66

7-
authorize :read_namespace_project
7+
field :flow, Types::FlowType, null: true, description: 'Fetches an flow given by its ID' do
8+
argument :id, Types::GlobalIdType[::Flow], required: true, description: 'Id of the flow'
9+
end
810

911
field :description, String, null: false, description: 'Description of the project'
12+
1013
field :name, String, null: false, description: 'Name of the project'
14+
1115
field :runtimes, Types::RuntimeType.connection_type, null: false, description: 'Runtimes assigned to this project'
1216

1317
field :namespace, Types::NamespaceType, null: false,
1418
description: 'The namespace where this project belongs to'
19+
1520
field :primary_runtime, Types::RuntimeType, null: true, description: 'The primary runtime for the project'
1621

22+
field :flows, Types::FlowType.connection_type, null: true, description: 'Fetches all flows in this project'
23+
24+
def flows
25+
project = context.schema.object_from_id(id, context)
26+
27+
project.flows
28+
end
29+
30+
def flow(id:)
31+
context.schema.object_from_id(id, context).flows.find(id: id)
32+
end
33+
34+
authorize :read_namespace_project
35+
1736
id_field NamespaceProject
1837
timestamps
1938
end

app/graphql/types/query_type.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ 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-
157
field :node, Types::NodeType, null: true, description: 'Fetches an object given its ID' do
168
argument :id, ID, required: true, description: 'ID of the object'
179
end
@@ -50,16 +42,6 @@ class QueryType < Types::BaseObject
5042

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

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-
6345
def node(id:)
6446
context.schema.object_from_id(id, context)
6547
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: FlowConnection
3+
---
4+
5+
The connection type for Flow.
6+
7+
## Fields without arguments
8+
9+
| Name | Type | Description |
10+
|------|------|-------------|
11+
| `count` | [`Int!`](../scalar/int.md) | Total count of collection. |
12+
| `edges` | [`[FlowEdge]`](../object/flowedge.md) | A list of edges. |
13+
| `nodes` | [`[Flow]`](../object/flow.md) | A list of nodes. |
14+
| `pageInfo` | [`PageInfo!`](../object/pageinfo.md) | Information to aid in pagination. |
15+

docs/graphql/object/flowedge.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: FlowEdge
3+
---
4+
5+
An edge in a connection.
6+
7+
## Fields without arguments
8+
9+
| Name | Type | Description |
10+
|------|------|-------------|
11+
| `cursor` | [`String!`](../scalar/string.md) | A cursor for use in pagination. |
12+
| `node` | [`Flow`](../object/flow.md) | The item at the end of the edge. |
13+

docs/graphql/object/namespaceproject.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,22 @@ Represents a namespace project
1010
|------|------|-------------|
1111
| `createdAt` | [`Time!`](../scalar/time.md) | Time when this NamespaceProject was created |
1212
| `description` | [`String!`](../scalar/string.md) | Description of the project |
13+
| `flows` | [`FlowConnection`](../object/flowconnection.md) | Fetches all flows in this project |
1314
| `id` | [`NamespaceProjectID!`](../scalar/namespaceprojectid.md) | Global ID of this NamespaceProject |
1415
| `name` | [`String!`](../scalar/string.md) | Name of the project |
1516
| `namespace` | [`Namespace!`](../object/namespace.md) | The namespace where this project belongs to |
1617
| `primaryRuntime` | [`Runtime`](../object/runtime.md) | The primary runtime for the project |
1718
| `runtimes` | [`RuntimeConnection!`](../object/runtimeconnection.md) | Runtimes assigned to this project |
1819
| `updatedAt` | [`Time!`](../scalar/time.md) | Time when this NamespaceProject was last updated |
1920

21+
## Fields with arguments
22+
23+
### flow
24+
25+
Fetches an flow given by its ID
26+
27+
Returns [`Flow`](../object/flow.md).
28+
29+
| Name | Type | Description |
30+
|------|------|-------------|
31+
| `id` | [`FlowID!`](../scalar/flowid.md) | Id of the flow |

docs/graphql/object/query.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,6 @@ 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-
4929
### namespace
5030

5131
Find a namespace

spec/graphql/types/namespace_project_type_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
namespace
1212
primary_runtime
1313
runtimes
14+
flows
15+
flow
1416
created_at
1517
updated_at
1618
]

spec/graphql/types/query_type_spec.rb

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

0 commit comments

Comments
 (0)