decidim-api 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/decidim/api.rb +9 -0
- data/lib/decidim/api/graphiql-initial-query.txt +5 -1
- data/lib/decidim/api/schema.rb +7 -4
- data/lib/decidim/api/test/type_context.rb +34 -13
- data/lib/decidim/api/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05add51fe4018279985a7f4739aefdfff87fd515b7f171a1fa7c1209d42560d0
|
4
|
+
data.tar.gz: 4b143d0582b2d391e3fdf711af978108cfb29f17e1537d15dfcbbdb8c2709b9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad462fc43e876f472c9a7a2e2ed0f2a634a5ced16398fe8b0987465379e2c619c4c53db0bc4e579f41a9658ab0b375bf4fb5d217c4762292fb6e81a7410ee4b
|
7
|
+
data.tar.gz: 581a03e98744d0b21fc5a6433a85c6aa9e7ca811c4573ef09e6064ec49a74860282e732c5eb3fee76c720e0411bfe38e82f30fccea6791aab56e696a4c3baa35
|
data/lib/decidim/api.rb
CHANGED
@@ -9,5 +9,14 @@ module Decidim
|
|
9
9
|
autoload :MutationType, "decidim/api/mutation_type"
|
10
10
|
autoload :QueryType, "decidim/api/query_type"
|
11
11
|
autoload :Schema, "decidim/api/schema"
|
12
|
+
|
13
|
+
# This declares all the types an interface or union can resolve to. This needs
|
14
|
+
# to be done in order to be able to have them found. This is a shortcoming of
|
15
|
+
# graphql-ruby and the way it deals with loading types, in combination with
|
16
|
+
# rail's infamous autoloading.
|
17
|
+
def self.orphan_types
|
18
|
+
Decidim.feature_manifests.map(&:query_type).map(&:constantize).uniq +
|
19
|
+
Decidim.participatory_space_manifests.map(&:query_type).map(&:constantize).uniq
|
20
|
+
end
|
12
21
|
end
|
13
22
|
end
|
data/lib/decidim/api/schema.rb
CHANGED
@@ -7,10 +7,13 @@ module Decidim
|
|
7
7
|
query QueryType
|
8
8
|
mutation MutationType
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
default_max_page_size 50
|
11
|
+
max_depth 10
|
12
|
+
max_complexity 300
|
13
|
+
|
14
|
+
orphan_types(Api.orphan_types)
|
15
|
+
|
16
|
+
resolve_type ->(_type, _obj, _ctx) {}
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -4,32 +4,30 @@ shared_context "with a graphql type" do
|
|
4
4
|
let!(:current_organization) { create(:organization) }
|
5
5
|
let!(:current_user) { create(:user, organization: current_organization) }
|
6
6
|
let(:model) { OpenStruct.new({}) }
|
7
|
+
let(:type_class) { described_class }
|
8
|
+
let(:variables) { {} }
|
9
|
+
let(:root_value) { model }
|
7
10
|
|
8
11
|
let(:schema) do
|
9
|
-
|
10
|
-
type_class = described_class
|
12
|
+
klass = type_class
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
GraphQL::Schema.define do
|
15
|
+
query klass
|
14
16
|
|
15
|
-
|
16
|
-
resolve resolver
|
17
|
-
end
|
18
|
-
end
|
17
|
+
orphan_types(Decidim::Api.orphan_types)
|
19
18
|
|
20
|
-
GraphQL::Schema.define do
|
21
|
-
query query_type
|
22
19
|
resolve_type ->(_type, _obj, _ctx) {}
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
26
23
|
let(:response) do
|
27
|
-
execute_query
|
24
|
+
execute_query query, variables.stringify_keys
|
28
25
|
end
|
29
26
|
|
30
|
-
def execute_query(query, variables
|
27
|
+
def execute_query(query, variables)
|
31
28
|
result = schema.execute(
|
32
29
|
query,
|
30
|
+
root_value: root_value,
|
33
31
|
context: {
|
34
32
|
current_organization: current_organization,
|
35
33
|
current_user: current_user
|
@@ -38,6 +36,29 @@ shared_context "with a graphql type" do
|
|
38
36
|
)
|
39
37
|
|
40
38
|
raise Exception, result["errors"].map { |e| e["message"] }.join(", ") if result["errors"]
|
41
|
-
result["data"]
|
39
|
+
result["data"]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
shared_context "with a graphql scalar type" do
|
44
|
+
include_context "with a graphql type"
|
45
|
+
|
46
|
+
let(:root_value) do
|
47
|
+
OpenStruct.new(value: model)
|
48
|
+
end
|
49
|
+
|
50
|
+
let(:type_class) do
|
51
|
+
klass = described_class
|
52
|
+
|
53
|
+
GraphQL::ObjectType.define do
|
54
|
+
name "Test#{klass.name}"
|
55
|
+
description "Fake test type"
|
56
|
+
|
57
|
+
field :value, klass
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
let(:response) do
|
62
|
+
execute_query("{ value }", {}).try(:[], "value")
|
42
63
|
end
|
43
64
|
end
|
data/lib/decidim/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-03-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: graphiql-rails
|
@@ -74,56 +74,56 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - '='
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.
|
77
|
+
version: 0.10.0
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - '='
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 0.
|
84
|
+
version: 0.10.0
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: decidim-core
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - '='
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.
|
91
|
+
version: 0.10.0
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - '='
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0.
|
98
|
+
version: 0.10.0
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: decidim-dev
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - '='
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.
|
105
|
+
version: 0.10.0
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - '='
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
112
|
+
version: 0.10.0
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: decidim-participatory_processes
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - '='
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: 0.
|
119
|
+
version: 0.10.0
|
120
120
|
type: :development
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
124
|
- - '='
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: 0.
|
126
|
+
version: 0.10.0
|
127
127
|
description: API engine for decidim
|
128
128
|
email:
|
129
129
|
- josepjaume@gmail.com
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.7.
|
177
|
+
rubygems_version: 2.7.6
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Decidim API module
|