osso 0.0.3.9 → 0.0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/osso/graphql/query.rb +4 -1
- data/lib/osso/graphql/resolvers/enterprise_accounts.rb +12 -4
- data/lib/osso/graphql/types/base_connection.rb +15 -0
- data/lib/osso/graphql/types/base_object.rb +2 -0
- data/lib/osso/graphql/types.rb +1 -0
- data/lib/osso/version.rb +1 -1
- data/spec/graphql/query/enterprise_accounts_spec.rb +32 -18
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffe9bf4e6f4de963af60c998d318a471e1ff3e33ef5a6c544c8923de762020bc
|
4
|
+
data.tar.gz: a994f84634c584268e517688ec62b61315da4fa1ab2ea05787305b34deb964f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c4e301385bb83a8ca5f7d66e4a3b3383c7ea3f58f395dc83e1cbadadb2a6896e1852ed787ae9a33a37a2871c3d5c28e5f33e072b7980ad904f958e95b4addb8
|
7
|
+
data.tar.gz: 8529f13cc30d05946b7fa798b117483dd20b9415d27b6caccecfff228a666b73bfd1f36ceb7e19d7977803159a56aff0eca9075cb380fe7fde3ce560a1847217
|
data/Gemfile.lock
CHANGED
data/lib/osso/graphql/query.rb
CHANGED
@@ -4,7 +4,10 @@ module Osso
|
|
4
4
|
module GraphQL
|
5
5
|
module Types
|
6
6
|
class QueryType < ::GraphQL::Schema::Object
|
7
|
-
field :enterprise_accounts, null: true, resolver: Resolvers::EnterpriseAccounts
|
7
|
+
field :enterprise_accounts, null: true, resolver: Resolvers::EnterpriseAccounts do
|
8
|
+
argument :sort_column, String, required: false
|
9
|
+
argument :sort_order, String, required: false
|
10
|
+
end
|
8
11
|
field :oauth_clients, null: true, resolver: Resolvers::OAuthClients
|
9
12
|
|
10
13
|
field :enterprise_account, null: true, resolver: Resolvers::EnterpriseAccount do
|
@@ -4,12 +4,20 @@ module Osso
|
|
4
4
|
module GraphQL
|
5
5
|
module Resolvers
|
6
6
|
class EnterpriseAccounts < ::GraphQL::Schema::Resolver
|
7
|
-
type
|
7
|
+
type Types::EnterpriseAccount.connection_type, null: true
|
8
8
|
|
9
|
-
def resolve
|
10
|
-
return Osso::Models::EnterpriseAccount.
|
9
|
+
def resolve(sort_column: nil, sort_order: nil)
|
10
|
+
return Array(Osso::Models::EnterpriseAccount.find_by(domain: context[:scope])) if context[:scope] != :admin
|
11
11
|
|
12
|
-
|
12
|
+
accounts = Osso::Models::EnterpriseAccount
|
13
|
+
|
14
|
+
accounts = accounts.order(sort_column => sort_order_sym(sort_order)) if sort_column && sort_order
|
15
|
+
|
16
|
+
accounts.all
|
17
|
+
end
|
18
|
+
|
19
|
+
def sort_order_sym(order_string)
|
20
|
+
order_string == 'ascend' ? :asc : :desc
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Osso
|
4
|
+
module GraphQL
|
5
|
+
module Types
|
6
|
+
class BaseConnection < ::GraphQL::Types::Relay::BaseConnection
|
7
|
+
field :total_count, Integer, null: false
|
8
|
+
|
9
|
+
def total_count
|
10
|
+
object.items&.count
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -6,6 +6,8 @@ module Osso
|
|
6
6
|
module GraphQL
|
7
7
|
module Types
|
8
8
|
class BaseObject < ::GraphQL::Schema::Object
|
9
|
+
connection_type_class GraphQL::Types::BaseConnection
|
10
|
+
|
9
11
|
field :created_at, ::GraphQL::Types::ISO8601DateTime, null: false
|
10
12
|
field :updated_at, ::GraphQL::Types::ISO8601DateTime, null: false
|
11
13
|
end
|
data/lib/osso/graphql/types.rb
CHANGED
data/lib/osso/version.rb
CHANGED
@@ -7,37 +7,51 @@ describe Osso::GraphQL::Schema do
|
|
7
7
|
describe 'for an admin user' do
|
8
8
|
let(:current_scope) { :admin }
|
9
9
|
|
10
|
-
it 'returns Enterprise Accounts' do
|
11
|
-
|
10
|
+
it 'returns paginated Enterprise Accounts' do
|
11
|
+
%w[A B C].map do |name|
|
12
|
+
create(:enterprise_account, name: name)
|
13
|
+
end
|
12
14
|
|
13
15
|
query = <<~GRAPHQL
|
14
|
-
query EnterpriseAccounts {
|
15
|
-
enterpriseAccounts {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
query EnterpriseAccounts($first: Int, $sortColumn: String, $sortOrder: String) {
|
17
|
+
enterpriseAccounts(first: $first, sortColumn: $sortColumn, sortOrder: $sortOrder) {
|
18
|
+
pageInfo {
|
19
|
+
hasNextPage
|
20
|
+
endCursor
|
21
|
+
}
|
22
|
+
totalCount
|
23
|
+
edges {
|
24
|
+
node {
|
25
|
+
domain
|
26
|
+
id
|
27
|
+
identityProviders {
|
28
|
+
id
|
29
|
+
service
|
30
|
+
domain
|
31
|
+
acsUrl
|
32
|
+
ssoCert
|
33
|
+
ssoUrl
|
34
|
+
status
|
35
|
+
}
|
36
|
+
name
|
37
|
+
status
|
38
|
+
}
|
26
39
|
}
|
27
|
-
name
|
28
|
-
status
|
29
40
|
}
|
30
41
|
}
|
31
42
|
GRAPHQL
|
32
43
|
|
33
44
|
response = described_class.execute(
|
34
45
|
query,
|
35
|
-
variables:
|
46
|
+
variables: { first: 2, sortOrder: 'descending', sortColumn: 'name' },
|
36
47
|
context: { scope: current_scope },
|
37
48
|
)
|
38
49
|
|
39
50
|
expect(response['errors']).to be_nil
|
40
|
-
expect(response.dig('data', 'enterpriseAccounts').count).to eq(2)
|
51
|
+
expect(response.dig('data', 'enterpriseAccounts', 'edges').count).to eq(2)
|
52
|
+
expect(response.dig('data', 'enterpriseAccounts', 'edges', 0, 'node', 'name')).to eq('C')
|
53
|
+
expect(response.dig('data', 'enterpriseAccounts', 'totalCount')).to eq(3)
|
54
|
+
expect(response.dig('data', 'enterpriseAccounts', 'pageInfo', 'hasNextPage')).to eq(true)
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Bauch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -285,6 +285,7 @@ files:
|
|
285
285
|
- lib/osso/graphql/resolvers/oauth_clients.rb
|
286
286
|
- lib/osso/graphql/schema.rb
|
287
287
|
- lib/osso/graphql/types.rb
|
288
|
+
- lib/osso/graphql/types/base_connection.rb
|
288
289
|
- lib/osso/graphql/types/base_enum.rb
|
289
290
|
- lib/osso/graphql/types/base_input_object.rb
|
290
291
|
- lib/osso/graphql/types/base_object.rb
|