decidim-api 0.27.4 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,9 @@
1
1
  /* eslint-disable require-jsdoc */
2
2
 
3
3
  import "entrypoints/decidim_api_graphiql.scss";
4
+ // Styles from node_modules/graphiql/graphiql.css
5
+ // It needs to be done in JS because postcss-import does not find files in node_modules/
6
+ import "graphiql/graphiql.css"
4
7
 
5
8
  import React from "react";
6
9
  import ReactDOM from "react-dom";
@@ -1,10 +1,8 @@
1
1
  html,
2
2
  body,
3
- #graphiql-container{
3
+ #graphiql-container {
4
4
  height: 100%;
5
5
  margin: 0;
6
6
  overflow: hidden;
7
7
  width: 100%;
8
8
  }
9
-
10
- @import "graphiql/graphiql.css";
@@ -1,5 +1,5 @@
1
1
  <div class="content"><%= contents %></div>
2
- <div id="sidebar"><%= include.("sidebar.html") %></div>
2
+ <div id="sidebar"><%= include.call("sidebar.html") %></div>
3
3
 
4
4
  <!-- mobile only -->
5
5
  <div id="mobile-header">
data/docs/usage.md CHANGED
@@ -1,3 +1,5 @@
1
+ <!-- markdownlint-disable-file link-fragments -->
2
+
1
3
  ## About the GraphQL API
2
4
 
3
5
  [Decidim](https://github.com/decidim/decidim) comes with an API that follows the [GraphQL](https://graphql.org/) specification. It has a comprehensive coverage of all the public content that can be found on the website.
@@ -16,7 +18,7 @@ The GraphQL format is a JSON formatted text that is specified in a query. Respon
16
18
 
17
19
  For instance, you can check the version of a Decidim installation by using `curl` in the terminal:
18
20
 
19
- ```
21
+ ```bash
20
22
  curl -sSH "Content-Type: application/json" \
21
23
  -d '{"query": "{ decidim { version } }"}' \
22
24
  https://www.decidim.barcelona/api/
@@ -26,7 +28,7 @@ Note that `Content-Type` needs to be specified.
26
28
 
27
29
  The query can also be used in GraphiQL, in that case you can skip the `"query"` text:
28
30
 
29
- ```
31
+ ```graphql
30
32
  {
31
33
  decidim {
32
34
  version
@@ -66,7 +68,7 @@ Each "Type" is just a pre-defined structure with fields, or just an Scalar (Stri
66
68
 
67
69
  For instance, to obtain *all the participatory processes in a Decidim installation published since January 2018* and order them by published date, we could execute the next query:
68
70
 
69
- ```
71
+ ```graphql
70
72
  {
71
73
  participatoryProcesses(filter: {publishedSince: "2018-01-01"}, order: {publishedAt: "asc"}) {
72
74
  slug
@@ -79,7 +81,7 @@ For instance, to obtain *all the participatory processes in a Decidim installati
79
81
 
80
82
  Response should look like:
81
83
 
82
- ```
84
+ ```json
83
85
  {
84
86
  "data": {
85
87
  "participatoryProcesses": [
@@ -106,10 +108,10 @@ In the former query, each keyword represents a type, the words `publishedSince`,
106
108
 
107
109
  The other keywords however, are objects representing certain entities:
108
110
 
109
- - `participatoryProcesses` is a type that represents a collection of participatory spaces. It accepts arguments (`filter` and `order`), which are other object types as well. `slug` and `title` are the fields of the participatory process we are interested in, there are "Types" too.
110
- - `filter` is a [ParticipatoryProcessFilter](#ParticipatoryProcessFilter)\* input type, it has several properties that allows us to refine our search. One of them is the `publishedSince` property with the initial date from which to list entries.
111
- - `order ` is a [ParticipatoryProcessSort](#ParticipatoryProcessSort) type, works the same way as the filter but with the goal of ordering the results.
112
- - `title` is a [TranslatedField](#TranslatedField) type, which allows us to deal with multi-language fields.
111
+ * `participatoryProcesses` is a type that represents a collection of participatory spaces. It accepts arguments (`filter` and `order`), which are other object types as well. `slug` and `title` are the fields of the participatory process we are interested in, there are "Types" too.
112
+ * `filter` is a [ParticipatoryProcessFilter](#ParticipatoryProcessFilter)\* input type, it has several properties that allows us to refine our search. One of them is the `publishedSince` property with the initial date from which to list entries.
113
+ * `order` is a [ParticipatoryProcessSort](#ParticipatoryProcessSort) type, works the same way as the filter but with the goal of ordering the results.
114
+ * `title` is a [TranslatedField](#TranslatedField) type, which allows us to deal with multi-language fields.
113
115
 
114
116
  Finally, note that the returned object is an array, each item of which is a representation of the object we requested.
115
117
 
@@ -117,20 +119,20 @@ Finally, note that the returned object is an array, each item of which is a repr
117
119
  >
118
120
  > There are two types of objects to filter and ordering collections in Decidim, they all work in a similar fashion. The type involved in filtering always have the suffix "Filter", for ordering it has the suffix "Sort".
119
121
  >
120
- > The types used to filter participatory spaces are: [ParticipatoryProcessFilter](#ParticipatoryProcessFilter), [AssemblyFilter](#AssemblyFilter), [ConsultationFilter](#ConsultationFilter) and so on.
122
+ > The types used to filter participatory spaces are: [ParticipatoryProcessFilter](#ParticipatoryProcessFilter), [AssemblyFilter](#AssemblyFilter), and so on.
121
123
  >
122
124
  > Other collections (or connections) may have their own filters (i.e. [ComponentFilter](#ComponentFilter)).
123
125
  >
124
126
  > Each filter has its own properties, you should check any object in particular for details. The way they work with multi-languages fields, however, is the same:
125
127
  >
126
- > Let's say we have some searchable object with a multi-language field called *title*, and we have a filter that allows us to search through this field. How should it work? Should we look up content for every language in the field? or should we stick to a specific language?
128
+ > We can say we have some searchable object with a multi-language field called *title*, and we have a filter that allows us to search through this field. How should it work? Should we look up content for every language in the field? or should we stick to a specific language?
127
129
  >
128
- > In our case, we've decided to search only one particular language of a multi-language field but we let you choose which language to search.
130
+ > In our case, we have decided to search only one particular language of a multi-language field but we let you choose which language to search.
129
131
  > If no language is specified, the configured as default in the organization will be used. The keyword to specify the language is `locale`, and it should be provided in the 2 letters ISO 639-1 format (en = English, es = Spanish, ...).
130
132
  >
131
133
  > Example (this is not a real Decidim query):
132
134
  >
133
- > ```
135
+ > ```graphql
134
136
  > some_collection(filter: { locale: "en", title: "ideas"}) {
135
137
  > id
136
138
  > }
@@ -142,7 +144,7 @@ Finally, note that the returned object is an array, each item of which is a repr
142
144
  >
143
145
  > Example of ordering alphabetically by the title content in French language:
144
146
  >
145
- > ```
147
+ > ```graphql
146
148
  > some_collection(order: { locale: "en", title: "asc"}) {
147
149
  > id
148
150
  > }
@@ -154,13 +156,13 @@ Finally, note that the returned object is an array, each item of which is a repr
154
156
 
155
157
  Decidim has 2 main types of objects through which content is provided. These are Participatory Spaces and Components.
156
158
 
157
- A participatory space is the first level, currently there are 5 officially supported: *Participatory Processes*, *Assemblies*, *Consultations*, *Conferences* and *Initiatives*. For each participatory process there will correspond a collection type and a "single item" type.
159
+ A participatory space is the first level, currently there are 5 officially supported: *Participatory Processes*, *Assemblies*, *Conferences* and *Initiatives*. For each participatory process there will correspond a collection type and a "single item" type.
158
160
 
159
- The previous example uses the collection type for participatory processes. You can try `assemblies`, `conferences`, `consultations` or `initiatives` for the others. Note that each collection can implement their own filter and order types with different properties.
161
+ The previous example uses the collection type for participatory processes. You can try `assemblies`, `conferences`, or `initiatives` for the others. Note that each collection can implement their own filter and order types with different properties.
160
162
 
161
163
  As an example for a single item query, you can run:
162
164
 
163
- ```
165
+ ```graphql
164
166
  {
165
167
  participatoryProcess(slug: "consectetur-at") {
166
168
  slug
@@ -173,7 +175,7 @@ As an example for a single item query, you can run:
173
175
 
174
176
  And the response will be:
175
177
 
176
- ```
178
+ ```json
177
179
  {
178
180
  "data": {
179
181
  "participatoryProcess": {
@@ -186,7 +188,7 @@ And the response will be:
186
188
  }
187
189
  ```
188
190
 
189
- #### What's different?
191
+ #### What is different?
190
192
 
191
193
  First, note that we are querying, in singular, the type `participatoryProcess`, with a different parameter, `slug`\*, (a String). We can use the `id` instead if we know it.
192
194
 
@@ -206,7 +208,7 @@ Every participatory space may (and should) have some components. There are 9 off
206
208
 
207
209
  If you know the `id`\* of a specific component you can obtain it by querying it directly:
208
210
 
209
- ```
211
+ ```graphql
210
212
  {
211
213
  component(id:2) {
212
214
  id
@@ -224,7 +226,7 @@ If you know the `id`\* of a specific component you can obtain it by querying it
224
226
 
225
227
  Response:
226
228
 
227
- ```
229
+ ```json
228
230
  {
229
231
  "data": {
230
232
  "component": {
@@ -250,13 +252,13 @@ The process is analogue as what has been explained in the case of searching for
250
252
  >
251
253
  > In this case, 3257.
252
254
 
253
- #### What about component's collections?
255
+ ##### What about component's collections?
254
256
 
255
257
  Glad you asked, component's collections cannot be retrieved directly, the are available *in the context* of a participatory space.
256
258
 
257
259
  For instance, we can query all the components in an particular Assembly as follows:
258
260
 
259
- ```
261
+ ```graphql
260
262
  {
261
263
  assembly(id: 3) {
262
264
  components {
@@ -272,7 +274,7 @@ For instance, we can query all the components in an particular Assembly as follo
272
274
 
273
275
  The response will be similar to:
274
276
 
275
- ```
277
+ ```json
276
278
  {
277
279
  "data": {
278
280
  "assembly": {
@@ -313,7 +315,7 @@ The response will be similar to:
313
315
 
314
316
  We can also apply some filters by using the [ComponentFilter](#ComponentFilter) type. In the next query we would like to *find all the components with geolocation enabled in the assembly with id=2*:
315
317
 
316
- ```
318
+ ```graphql
317
319
  {
318
320
  assembly(id: 2) {
319
321
  components(filter: {withGeolocationEnabled: true}) {
@@ -329,7 +331,7 @@ We can also apply some filters by using the [ComponentFilter](#ComponentFilter)
329
331
 
330
332
  The response:
331
333
 
332
- ```
334
+ ```json
333
335
  {
334
336
  "data": {
335
337
  "assembly": {
@@ -357,14 +359,13 @@ For instance, components in a participatory space are polymorphic, while the con
357
359
 
358
360
  Another example are the case of linked resources, these are properties that may link objects of different nature between components or participatory spaces.
359
361
 
360
- In a very simplified way (to know more please refer to the official guide), GraphQL polymorphism is handled through the operator `... on`. You'll know when a field is polymorphic because the property `__typename`, which tells you the type of that particular object, will change accordingly.
362
+ In a very simplified way (to know more please refer to the official guide), GraphQL polymorphism is handled through the operator `... on`. You will know when a field is polymorphic because the property `__typename`, which tells you the type of that particular object, will change accordingly.
361
363
 
362
- In the previous examples we've queried for this property:
364
+ In the previous examples we have queried for this property:
363
365
 
364
366
  Response fragment:
365
367
 
366
- ```
367
- ...
368
+ ```json
368
369
  "components": [
369
370
  {
370
371
  "id": "38",
@@ -373,12 +374,11 @@ Response fragment:
373
374
  },
374
375
  "__typename": "Meetings"
375
376
  }
376
- ...
377
377
  ```
378
378
 
379
379
  So, if we want to access the rest of the properties in a polymorphic object, we should do it through the `... on` operator as follows:
380
380
 
381
- ```
381
+ ```graphql
382
382
  {
383
383
  assembly(id: 2) {
384
384
  components {
@@ -393,7 +393,7 @@ So, if we want to access the rest of the properties in a polymorphic object, we
393
393
 
394
394
  Consider this query:
395
395
 
396
- ```
396
+ ```graphql
397
397
  {
398
398
  assembly(id: 3) {
399
399
  components(filter: {type: "Proposals"}) {
@@ -420,7 +420,7 @@ Consider this query:
420
420
 
421
421
  The response:
422
422
 
423
- ```
423
+ ```json
424
424
  {
425
425
  "data": {
426
426
  "assembly": {
@@ -491,9 +491,9 @@ The response:
491
491
  }
492
492
  ```
493
493
 
494
- #### What's going on?
494
+ #### What is going on?
495
495
 
496
- Until the `... on Proposals` line, there's nothing new. We are requesting the *Assembly* participatory space identified by the `id=3`, then listing all its components with the type "Proposals". All the components share the *id* and *name* properties, so we can just add them at the query.
496
+ Until the `... on Proposals` line, there is nothing new. We are requesting the *Assembly* participatory space identified by the `id=3`, then listing all its components with the type "Proposals". All the components share the *id* and *name* properties, so we can just add them at the query.
497
497
 
498
498
  After that, we want content specific from the *Proposals* type. In order to do that we must tell the server that the content we will request shall only be executed if the types matches *Proposals*. We do that by wrapping the rest of the query in the `... on Proposals` clause.
499
499
 
@@ -501,14 +501,14 @@ The next line is just a property of the type *Proposals* which is a type of coll
501
501
 
502
502
  Typically, a connection is used to paginate long results, for this purpose the results are not directly available but encapsulated inside the list *edges* in several *node* results. Also there are more arguments available in order to navigate between pages. This are the arguments:
503
503
 
504
- - `first`: Returns the first *n* elements from the list
505
- - `after`: Returns the elements in the list that come after the specified *cursor*
506
- - `last`: Returns the last *n* elements from the list
507
- - `before`: Returns the elements in the list that come before the specified *cursor*
504
+ * `first`: Returns the first *n* elements from the list
505
+ * `after`: Returns the elements in the list that come after the specified *cursor*
506
+ * `last`: Returns the last *n* elements from the list
507
+ * `before`: Returns the elements in the list that come before the specified *cursor*
508
508
 
509
509
  Example:
510
510
 
511
- ```
511
+ ```graphql
512
512
  {
513
513
  assembly(id: 3) {
514
514
  components(filter: {type: "Proposals"}) {
@@ -541,7 +541,7 @@ Example:
541
541
 
542
542
  Being the response:
543
543
 
544
- ```
544
+ ```json
545
545
  {
546
546
  "data": {
547
547
  "assembly": {
@@ -592,5 +592,3 @@ As you can see, a part from the *edges* list, you can access to the object *page
592
592
  For more info on how connections work, you can check the official guide:
593
593
 
594
594
  https://graphql.org/learn/pagination/
595
-
596
-
@@ -23,7 +23,7 @@ module Decidim
23
23
  class Engine < ::Rails::Engine
24
24
  isolate_namespace Decidim::Api
25
25
 
26
- initializer "decidim-api.middleware" do |app|
26
+ initializer "decidim_api.middleware" do |app|
27
27
  app.config.middleware.insert_before 0, Rack::Cors do
28
28
  allow do
29
29
  origins "*"
@@ -32,7 +32,7 @@ module Decidim
32
32
  end
33
33
  end
34
34
 
35
- initializer "decidim-api.graphiql" do
35
+ initializer "decidim_api.graphiql" do
36
36
  Decidim::GraphiQL::Rails.config.tap do |config|
37
37
  config.query_params = true
38
38
  config.initial_query = File.read(
@@ -23,12 +23,12 @@ shared_context "with a graphql class type" do
23
23
  def execute_query(query, variables)
24
24
  result = schema.execute(
25
25
  query,
26
- root_value: root_value,
26
+ root_value:,
27
27
  context: {
28
- current_organization: current_organization,
29
- current_user: current_user
28
+ current_organization:,
29
+ current_user:
30
30
  },
31
- variables: variables
31
+ variables:
32
32
  )
33
33
 
34
34
  raise StandardError, result["errors"].map { |e| e["message"] }.join(", ") if result["errors"]
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-api version.
5
5
  module Api
6
6
  def self.version
7
- "0.27.4"
7
+ "0.28.0.rc4"
8
8
  end
9
9
  end
10
10
  end
@@ -9,7 +9,7 @@ namespace :decidim_api do
9
9
 
10
10
  GraphQLDocs.build(
11
11
  schema: Decidim::Api::Schema,
12
- output_dir: output_dir,
12
+ output_dir:,
13
13
  base_url: "/api/docs",
14
14
  landing_pages: {
15
15
  index: File.expand_path("../../docs/usage.md", __dir__)
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.27.4
4
+ version: 0.28.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,42 +10,56 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-07-27 00:00:00.000000000 Z
13
+ date: 2023-12-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: graphql
16
+ name: commonmarker
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.12'
22
- - - "<"
21
+ version: 0.23.0
22
+ - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: '1.13'
24
+ version: 0.23.9
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - "~>"
30
30
  - !ruby/object:Gem::Version
31
- version: '1.12'
32
- - - "<"
31
+ version: 0.23.0
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.23.9
35
+ - !ruby/object:Gem::Dependency
36
+ name: graphql
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 2.0.0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: '1.13'
48
+ version: 2.0.0
35
49
  - !ruby/object:Gem::Dependency
36
50
  name: graphql-docs
37
51
  requirement: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
- version: 2.1.0
55
+ version: 3.0.1
42
56
  type: :runtime
43
57
  prerelease: false
44
58
  version_requirements: !ruby/object:Gem::Requirement
45
59
  requirements:
46
60
  - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: 2.1.0
62
+ version: 3.0.1
49
63
  - !ruby/object:Gem::Dependency
50
64
  name: rack-cors
51
65
  requirement: !ruby/object:Gem::Requirement
@@ -66,56 +80,56 @@ dependencies:
66
80
  requirements:
67
81
  - - '='
68
82
  - !ruby/object:Gem::Version
69
- version: 0.27.4
83
+ version: 0.28.0.rc4
70
84
  type: :development
71
85
  prerelease: false
72
86
  version_requirements: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - '='
75
89
  - !ruby/object:Gem::Version
76
- version: 0.27.4
90
+ version: 0.28.0.rc4
77
91
  - !ruby/object:Gem::Dependency
78
92
  name: decidim-core
79
93
  requirement: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - '='
82
96
  - !ruby/object:Gem::Version
83
- version: 0.27.4
97
+ version: 0.28.0.rc4
84
98
  type: :development
85
99
  prerelease: false
86
100
  version_requirements: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - '='
89
103
  - !ruby/object:Gem::Version
90
- version: 0.27.4
104
+ version: 0.28.0.rc4
91
105
  - !ruby/object:Gem::Dependency
92
106
  name: decidim-dev
93
107
  requirement: !ruby/object:Gem::Requirement
94
108
  requirements:
95
109
  - - '='
96
110
  - !ruby/object:Gem::Version
97
- version: 0.27.4
111
+ version: 0.28.0.rc4
98
112
  type: :development
99
113
  prerelease: false
100
114
  version_requirements: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - '='
103
117
  - !ruby/object:Gem::Version
104
- version: 0.27.4
118
+ version: 0.28.0.rc4
105
119
  - !ruby/object:Gem::Dependency
106
120
  name: decidim-participatory_processes
107
121
  requirement: !ruby/object:Gem::Requirement
108
122
  requirements:
109
123
  - - '='
110
124
  - !ruby/object:Gem::Version
111
- version: 0.27.4
125
+ version: 0.28.0.rc4
112
126
  type: :development
113
127
  prerelease: false
114
128
  version_requirements: !ruby/object:Gem::Requirement
115
129
  requirements:
116
130
  - - '='
117
131
  - !ruby/object:Gem::Version
118
- version: 0.27.4
132
+ version: 0.28.0.rc4
119
133
  description: API engine for decidim
120
134
  email:
121
135
  - josepjaume@gmail.com
@@ -140,7 +154,6 @@ files:
140
154
  - app/views/decidim/api/graphiql/show.html.erb
141
155
  - app/views/layouts/decidim/api/documentation.html.erb
142
156
  - config/assets.rb
143
- - config/environment.rb
144
157
  - config/routes.rb
145
158
  - docs/usage.md
146
159
  - lib/decidim/api.rb
@@ -166,10 +179,15 @@ files:
166
179
  - lib/decidim/api/types/base_union.rb
167
180
  - lib/decidim/api/version.rb
168
181
  - lib/tasks/decidim_api_docs.rake
169
- homepage: https://github.com/decidim/decidim
182
+ homepage: https://decidim.org
170
183
  licenses:
171
184
  - AGPL-3.0
172
- metadata: {}
185
+ metadata:
186
+ bug_tracker_uri: https://github.com/decidim/decidim/issues
187
+ documentation_uri: https://docs.decidim.org/
188
+ funding_uri: https://opencollective.com/decidim
189
+ homepage_uri: https://decidim.org
190
+ source_code_uri: https://github.com/decidim/decidim
173
191
  post_install_message:
174
192
  rdoc_options: []
175
193
  require_paths:
@@ -178,14 +196,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
196
  requirements:
179
197
  - - ">="
180
198
  - !ruby/object:Gem::Version
181
- version: '3.0'
199
+ version: '3.1'
182
200
  required_rubygems_version: !ruby/object:Gem::Requirement
183
201
  requirements:
184
- - - ">="
202
+ - - ">"
185
203
  - !ruby/object:Gem::Version
186
- version: '0'
204
+ version: 1.3.1
187
205
  requirements: []
188
- rubygems_version: 3.2.22
206
+ rubygems_version: 3.4.20
189
207
  signing_key:
190
208
  specification_version: 4
191
209
  summary: Decidim API module
File without changes