Skip to content

Commit

Permalink
fix: added missing cursor (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmanilo authored May 11, 2023
1 parent b58ec6b commit 389b638
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion twingate/internal/client/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func (client *Client) CreateGroup(ctx context.Context, input *model.Group) (*mod
gqlVar(input.Name, "name"),
gqlIDs(input.Users, "userIds"),
gqlNullableID(input.SecurityPolicyID, "securityPolicyId"),
gqlNullable("", query.CursorUsers),
)

response := query.CreateGroup{}
Expand All @@ -40,7 +41,10 @@ func (client *Client) ReadGroup(ctx context.Context, groupID string) (*model.Gro
return nil, opr.apiError(ErrGraphqlIDIsEmpty)
}

variables := newVars(gqlID(groupID))
variables := newVars(
gqlID(groupID),
gqlNullable("", query.CursorUsers),
)

response := query.ReadGroup{}
if err := client.query(ctx, &response, variables, opr, attr{id: groupID}); err != nil {
Expand All @@ -60,6 +64,7 @@ func (client *Client) ReadGroups(ctx context.Context, filter *model.GroupsFilter
variables := newVars(
gqlNullable(query.NewGroupFilterInput(filter), "filter"),
gqlNullable("", query.CursorGroups),
gqlNullable("", query.CursorUsers),
)

response := query.ReadGroups{}
Expand Down Expand Up @@ -104,6 +109,7 @@ func (client *Client) UpdateGroup(ctx context.Context, input *model.Group) (*mod
gqlVar(input.Name, "name"),
gqlIDs(input.Users, "addedUserIds"),
gqlNullableID(input.SecurityPolicyID, "securityPolicyId"),
gqlNullable("", query.CursorUsers),
)

response := query.UpdateGroup{}
Expand Down Expand Up @@ -147,6 +153,7 @@ func (client *Client) DeleteGroupUsers(ctx context.Context, groupID string, user
variables := newVars(
gqlID(groupID),
gqlIDs(userIDs, "removedUserIds"),
gqlNullable("", query.CursorUsers),
)

response := query.UpdateGroupRemoveUsers{}
Expand Down
2 changes: 1 addition & 1 deletion twingate/internal/client/query/group-read.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type gqlGroup struct {
IDName
IsActive bool
Type string
Users Users
Users Users `graphql:"users(after: $usersEndCursor)"`
SecurityPolicy gqlSecurityPolicy
}

Expand Down
8 changes: 7 additions & 1 deletion twingate/internal/client/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (client *Client) CreateResource(ctx context.Context, input *model.Resource)
gqlNullable(input.IsVisible, "isVisible"),
gqlNullable(input.IsBrowserShortcutEnabled, "isBrowserShortcutEnabled"),
gqlNullable(input.Alias, "alias"),
gqlNullable("", query.CursorUsers),
)

response := query.CreateResource{}
Expand Down Expand Up @@ -100,7 +101,10 @@ func (client *Client) ReadResource(ctx context.Context, resourceID string) (*mod
return nil, opr.apiError(ErrGraphqlIDIsEmpty)
}

variables := newVars(gqlID(resourceID))
variables := newVars(
gqlID(resourceID),
gqlNullable("", query.CursorUsers),
)

response := query.ReadResource{}
if err := client.query(ctx, &response, variables, opr, attr{id: resourceID}); err != nil {
Expand Down Expand Up @@ -171,6 +175,7 @@ func (client *Client) UpdateResource(ctx context.Context, input *model.Resource)
gqlNullable(input.IsVisible, "isVisible"),
gqlNullable(input.IsBrowserShortcutEnabled, "isBrowserShortcutEnabled"),
gqlNullable(input.Alias, "alias"),
gqlNullable("", query.CursorUsers),
)

response := query.UpdateResource{}
Expand Down Expand Up @@ -312,6 +317,7 @@ func (client *Client) DeleteResourceGroups(ctx context.Context, resourceID strin
variables := newVars(
gqlID(resourceID),
gqlIDs(deleteGroupIDs, "removedGroupIds"),
gqlNullable("", query.CursorUsers),
)

response := query.UpdateResourceRemoveGroups{}
Expand Down

0 comments on commit 389b638

Please sign in to comment.