Skip to content

Commit

Permalink
Removes graphql-style pagination in favour of classic LIMIT/OFFSET
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Murtagh <alan.murtagh@vorteil.io>
  • Loading branch information
alankm committed Jul 21, 2022
1 parent e45d81b commit 902c8fc
Show file tree
Hide file tree
Showing 282 changed files with 5,174 additions and 20,696 deletions.
6 changes: 2 additions & 4 deletions cmd/flow/directory.go
Expand Up @@ -53,10 +53,8 @@ var directoryCmd = &cobra.Command{

req := &grpc.DirectoryRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down
6 changes: 2 additions & 4 deletions cmd/flow/event-listeners.go
Expand Up @@ -24,10 +24,8 @@ var eventListenersCmd = &cobra.Command{

req := &grpc.EventListenersRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down
6 changes: 2 additions & 4 deletions cmd/flow/events.go
Expand Up @@ -24,10 +24,8 @@ var eventHistoryCmd = &cobra.Command{

req := &grpc.EventHistoryRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down
6 changes: 2 additions & 4 deletions cmd/flow/instance.go
Expand Up @@ -96,10 +96,8 @@ var instancesCmd = &cobra.Command{

req := &grpc.InstancesRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down
24 changes: 8 additions & 16 deletions cmd/flow/logs.go
Expand Up @@ -22,10 +22,8 @@ var serverLogsCmd = &cobra.Command{

req := &grpc.ServerLogsRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down Expand Up @@ -85,10 +83,8 @@ var namespaceLogsCmd = &cobra.Command{

req := &grpc.NamespaceLogsRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down Expand Up @@ -150,10 +146,8 @@ var workflowLogsCmd = &cobra.Command{

req := &grpc.WorkflowLogsRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down Expand Up @@ -216,10 +210,8 @@ var instanceLogsCmd = &cobra.Command{

req := &grpc.InstanceLogsRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down
9 changes: 3 additions & 6 deletions cmd/flow/main.go
Expand Up @@ -29,8 +29,7 @@ var (
addr string

stream bool
after, before string
first, last int32
limit, offset int32
orderField, orderDirection string
filterField, filterType, filterVal string

Expand Down Expand Up @@ -121,10 +120,8 @@ func main() {

func addPaginationFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&stream, "stream", false, "")
cmd.Flags().StringVar(&after, "after", "", "")
cmd.Flags().Int32Var(&first, "first", 0, "")
cmd.Flags().StringVar(&before, "before", "", "")
cmd.Flags().Int32Var(&last, "last", 0, "")
cmd.Flags().Int32Var(&limit, "limit", -1, "")
cmd.Flags().Int32Var(&offset, "offset", 0, "")
cmd.Flags().StringVar(&orderField, "order.field", "", "")
cmd.Flags().StringVar(&orderDirection, "order.direction", "", "")
cmd.Flags().StringVar(&filterField, "filter.field", "", "")
Expand Down
6 changes: 2 additions & 4 deletions cmd/flow/namespace.go
Expand Up @@ -45,10 +45,8 @@ var namespacesCmd = &cobra.Command{

req := &grpc.NamespacesRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down
6 changes: 2 additions & 4 deletions cmd/flow/secret.go
Expand Up @@ -24,10 +24,8 @@ var secretsCmd = &cobra.Command{

req := &grpc.SecretsRequest{
Pagination: &grpc.Pagination{
After: after,
First: first,
Before: before,
Last: last,
Limit: limit,
Offset: offset,
Order: []*grpc.PageOrder{{
Field: orderField,
Direction: orderDirection,
Expand Down
6 changes: 3 additions & 3 deletions cmd/flow/test.go
Expand Up @@ -345,10 +345,10 @@ func testsFullReset() error {
return err
}

for _, edge := range namespaces.Edges {
if strings.HasPrefix(edge.Node.Name, prefix) {
for _, result := range namespaces.Results {
if strings.HasPrefix(result.Name, prefix) {
_, err = c.DeleteNamespace(ctx, &grpc.DeleteNamespaceRequest{
Name: edge.Node.Name,
Name: result.Name,
Idempotent: true,
Recursive: true,
})
Expand Down
14 changes: 7 additions & 7 deletions cmd/flow/tests-directories.go
Expand Up @@ -664,13 +664,13 @@ func testDirectory(ctx context.Context, c grpc.FlowClient, namespace string) err
return err
}

if len(resp.Children.Edges) != 3 {
if len(resp.Children.Results) != 3 {
return errors.New("incorrect number of directory children")
}

if resp.Children.Edges[0].Node.Name != "a" ||
resp.Children.Edges[1].Node.Name != "b" ||
resp.Children.Edges[2].Node.Name != "c" {
if resp.Children.Results[0].Name != "a" ||
resp.Children.Results[1].Name != "b" ||
resp.Children.Results[2].Name != "c" {
return errors.New("incorrect directory children")
}

Expand Down Expand Up @@ -701,7 +701,7 @@ func testDirectoryStream(ctx context.Context, c grpc.FlowClient, namespace strin
return err
}

if len(resp.Children.Edges) != 0 {
if len(resp.Children.Results) != 0 {
return errors.New("unexpected nodes in test directory")
}

Expand All @@ -718,7 +718,7 @@ func testDirectoryStream(ctx context.Context, c grpc.FlowClient, namespace strin
return err
}

if len(resp.Children.Edges) != 1 {
if len(resp.Children.Results) != 1 {
return errors.New("incorrect data in test directory")
}

Expand All @@ -732,7 +732,7 @@ func testDirectoryStream(ctx context.Context, c grpc.FlowClient, namespace strin
}

resp, err = client.Recv()
if len(resp.Children.Edges) != 0 {
if len(resp.Children.Results) != 0 {
return errors.New("unexpected nodes in test directory")
}

Expand Down
42 changes: 21 additions & 21 deletions cmd/flow/tests-instance-common.go
Expand Up @@ -116,7 +116,7 @@ func testStartWorkflow(ctx context.Context, c grpc.FlowClient, namespace string)
return err
}

if len(logs.Edges) == 0 {
if len(logs.Results) == 0 {
return errors.New("missing instance logs")
}

Expand Down Expand Up @@ -199,8 +199,8 @@ states:
}

var found bool
for _, edge := range logs.Edges {
msg := edge.Node.Msg
for _, result := range logs.Results {
msg := result.Msg
if msg == `"Hello, world!"` {
found = true
break
Expand Down Expand Up @@ -292,8 +292,8 @@ states:
}

var found bool
for _, edge := range logs.Edges {
msg := edge.Node.Msg
for _, result := range logs.Results {
msg := result.Msg
if msg == `"Direktiv!"` {
found = true
break
Expand Down Expand Up @@ -385,8 +385,8 @@ states:
}

var found bool
for _, edge := range logs.Edges {
msg := edge.Node.Msg
for _, result := range logs.Results {
msg := result.Msg
if msg == `"Hello, Direktiv!"` {
found = true
break
Expand Down Expand Up @@ -480,8 +480,8 @@ states:
}

var found bool
for _, edge := range logs.Edges {
msg := edge.Node.Msg
for _, result := range logs.Results {
msg := result.Msg
if msg == `{
"Constant": 5,
"Name": "Direktiv"
Expand Down Expand Up @@ -1712,9 +1712,9 @@ states:
}

inst := new(grpc.Instance)
for _, edge := range instances.GetInstances().GetEdges() {
if strings.TrimPrefix(edge.GetNode().GetAs(), "/") == "testwf-timeout-subflow" {
inst = edge.GetNode()
for _, result := range instances.GetInstances().GetResults() {
if strings.TrimPrefix(result.GetAs(), "/") == "testwf-timeout-subflow" {
inst = result
}
}

Expand Down Expand Up @@ -1838,9 +1838,9 @@ states:
}

inst := new(grpc.Instance)
for _, edge := range instances.GetInstances().GetEdges() {
if strings.TrimPrefix(edge.GetNode().GetAs(), "/") == "testwf-timeout-subflow" {
inst = edge.GetNode()
for _, result := range instances.GetInstances().GetResults() {
if strings.TrimPrefix(result.GetAs(), "/") == "testwf-timeout-subflow" {
inst = result
}
}

Expand Down Expand Up @@ -1964,9 +1964,9 @@ states:
}

inst := new(grpc.Instance)
for _, edge := range instances.GetInstances().GetEdges() {
if strings.TrimPrefix(edge.GetNode().GetAs(), "/") == "testwf-timeout-subflow" {
inst = edge.GetNode()
for _, result := range instances.GetInstances().GetResults() {
if strings.TrimPrefix(result.GetAs(), "/") == "testwf-timeout-subflow" {
inst = result
}
}

Expand Down Expand Up @@ -2090,9 +2090,9 @@ states:
}

inst := new(grpc.Instance)
for _, edge := range instances.GetInstances().GetEdges() {
if strings.TrimPrefix(edge.GetNode().GetAs(), "/") == "testwf-timeout-subflow" {
inst = edge.GetNode()
for _, result := range instances.GetInstances().GetResults() {
if strings.TrimPrefix(result.GetAs(), "/") == "testwf-timeout-subflow" {
inst = result
}
}

Expand Down

0 comments on commit 902c8fc

Please sign in to comment.