graphql-docs 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbf28a678c378ebc2d54f6e5b7b24a05bd3eb577f144b9042fe11c4e7f34bd13
4
- data.tar.gz: 993ad8805892c0544128baabec9dfd4f5bfb1cf16fccbe5cc43c3373036fcbbd
3
+ metadata.gz: 6c2c88bc1065c52ba30b33a2dc65ddc2c72c61e4e20d0d001f09492cce5f24ea
4
+ data.tar.gz: 76fa1d45d5953b8a9ac9cfa38a97b3c6a33f5daf6880a113a90c37a623e9bf19
5
5
  SHA512:
6
- metadata.gz: 94e80febfa9d2c367182afd21b6a0d3e1206ec3d076a6b774ecfb96308648e4e582e818d1ac4f0b0734aaad514e46edac8a50f9ecb6baddf1370790e5eee7f38
7
- data.tar.gz: 549077a6761dd67e983ab2c6bb402d5d67cfecafde214ddc57a7580439012eeb6a68ae6f0ff2091076d56eb64449aae9c055d87dc6e8a9da3fec081f51806d76
6
+ metadata.gz: bf384c8d7749b01cfa3f78c578e6af5e9196cbc002eb6106bcedc2fd1b26197c7ea08160be3fd84017a078e455b845a9af290abce67829712200009af1039da8
7
+ data.tar.gz: adb18b1a5f02041c86ca0a314765efdf59ab992cf7b766796a8560491d1878b7045d695fbc38bd7c74ed7f02957b72fc05196521d1fabe883b1e021ada29570e
@@ -8,7 +8,7 @@ jobs:
8
8
 
9
9
  strategy:
10
10
  matrix:
11
- ruby-version: [3.3, 3.2, 3.1]
11
+ ruby-version: [3.4.0-preview2, 3.3, 3.2, 3.1]
12
12
 
13
13
  steps:
14
14
  - uses: actions/checkout@v2
data/.rubocop.yml CHANGED
@@ -6,3 +6,6 @@ Style/StringLiterals:
6
6
 
7
7
  Naming/FileName:
8
8
  Enabled: false
9
+
10
+ Layout/IndentationWidth:
11
+ Width: 2
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ A concise overview of the public-facing changes to the gem from version to versi
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## v5.1.0 - 2024-12-09
8
+
9
+ - List queries in the sidebar, similar to mutations. See https://github.com/brettchalupa/graphql-docs/pull/156. Thanks @denisahearn!
10
+ - Fix Sass `@import` deprecation
11
+ - Add ostruct and logger gems to dependencies since they're being removed from the Ruby standard library in a future release
12
+ - Test and fixture improvements
13
+
7
14
  ## v5.0.0 - 2024-07-03
8
15
 
9
16
  - **breaking**: The graphql gem 2.2.0+ breaks some of the parsing and displaying of comments from a GraphQL schema file
data/graphql-docs.gemspec CHANGED
@@ -44,9 +44,11 @@ Gem::Specification.new do |spec|
44
44
  spec.add_dependency 'gemoji', '~> 3.0'
45
45
  spec.add_dependency 'html-pipeline', '>= 2.14.3', '~> 2.14'
46
46
  spec.add_dependency 'sass-embedded', '~> 1.58'
47
+ spec.add_dependency 'ostruct', '~> 0.6'
48
+ spec.add_dependency 'logger', '~> 1.6'
47
49
 
48
50
  spec.add_development_dependency 'html-proofer', '~> 3.4'
49
- spec.add_development_dependency 'minitest', '~> 5.0'
51
+ spec.add_development_dependency 'minitest', '~> 5.24'
50
52
  spec.add_development_dependency 'minitest-focus', '~> 1.1'
51
53
  spec.add_development_dependency 'rake', '~> 13.0'
52
54
  spec.add_development_dependency 'rubocop', '~> 1.37'
@@ -32,6 +32,7 @@ module GraphQLDocs
32
32
 
33
33
  operations: "#{File.dirname(__FILE__)}/layouts/graphql_operations.html",
34
34
  objects: "#{File.dirname(__FILE__)}/layouts/graphql_objects.html",
35
+ queries: "#{File.dirname(__FILE__)}/layouts/graphql_queries.html",
35
36
  mutations: "#{File.dirname(__FILE__)}/layouts/graphql_mutations.html",
36
37
  interfaces: "#{File.dirname(__FILE__)}/layouts/graphql_interfaces.html",
37
38
  enums: "#{File.dirname(__FILE__)}/layouts/graphql_enums.html",
@@ -17,7 +17,7 @@ module GraphQLDocs
17
17
 
18
18
  @renderer = @options[:renderer].new(@parsed_schema, @options)
19
19
 
20
- %i[operations objects mutations interfaces enums unions input_objects scalars directives].each do |sym|
20
+ %i[operations objects queries mutations interfaces enums unions input_objects scalars directives].each do |sym|
21
21
  raise IOError, "`#{sym}` template #{@options[:templates][sym]} was not found" unless File.exist?(@options[:templates][sym])
22
22
 
23
23
  instance_variable_set("@graphql_#{sym}_template", ERB.new(File.read(@options[:templates][sym])))
@@ -52,8 +52,9 @@ module GraphQLDocs
52
52
  def generate
53
53
  FileUtils.rm_rf(@options[:output_dir]) if @options[:delete_output]
54
54
 
55
- has_query = create_graphql_query_pages
55
+ has_query = create_graphql_operation_pages
56
56
  create_graphql_object_pages
57
+ create_graphql_query_pages
57
58
  create_graphql_mutation_pages
58
59
  create_graphql_interface_pages
59
60
  create_graphql_enum_pages
@@ -96,7 +97,7 @@ module GraphQLDocs
96
97
  true
97
98
  end
98
99
 
99
- def create_graphql_query_pages
100
+ def create_graphql_operation_pages
100
101
  graphql_operation_types.each do |query_type|
101
102
  metadata = ''
102
103
  next unless query_type[:name] == graphql_root_types['query']
@@ -129,6 +130,15 @@ module GraphQLDocs
129
130
  end
130
131
  end
131
132
 
133
+ def create_graphql_query_pages
134
+ graphql_query_types.each do |query|
135
+ opts = default_generator_options(type: query)
136
+
137
+ contents = @graphql_queries_template.result(OpenStruct.new(opts).instance_eval { binding })
138
+ write_file('query', query[:name], contents)
139
+ end
140
+ end
141
+
132
142
  def create_graphql_mutation_pages
133
143
  graphql_mutation_types.each do |mutation|
134
144
  opts = default_generator_options(type: mutation)
@@ -36,6 +36,10 @@ module GraphQLDocs
36
36
  @parsed_schema[:operation_types] || []
37
37
  end
38
38
 
39
+ def graphql_query_types
40
+ @parsed_schema[:query_types] || []
41
+ end
42
+
39
43
  def graphql_mutation_types
40
44
  @parsed_schema[:mutation_types] || []
41
45
  end
@@ -1,4 +1,8 @@
1
1
  ---
2
2
  title: Queries
3
3
  ---
4
- Every GraphQL schema has a root type for both queries and mutations. The [query type](http://spec.graphql.org/draft/#sec-Type-System) defines GraphQL operations that retrieve data from the server.
4
+ Every GraphQL schema has a root type for both queries and mutations.
5
+
6
+ The query type defines GraphQL operations that retrieve data from the server.
7
+
8
+ For more information, see [the GraphQL spec](http://spec.graphql.org/draft/#sec-Type-System).
@@ -1,7 +1,8 @@
1
1
  @charset "utf-8";
2
2
 
3
- @import "../_sass/_normalize.scss";
4
- @import "../_sass/_fonts";
3
+ @use "sass:meta";
4
+ @use "../_sass/_normalize.scss";
5
+ @use "../_sass/_fonts";
5
6
 
6
7
  body {
7
8
  font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
@@ -39,11 +40,11 @@ em {
39
40
  font-family: 'ProximaNova-Semibold';
40
41
  }
41
42
 
42
- @import '../_sass/_header';
43
- @import '../_sass/_sidebar';
44
- @import '../_sass/_content';
45
- @import '../_sass/_types';
46
- @import '../_sass/_mobile';
47
- @import '../_sass/_api-box';
48
- @import '../_sass/_syntax';
49
- @import '../_sass/_deprecations';
43
+ @include meta.load-css('../_sass/_header');
44
+ @include meta.load-css('../_sass/_sidebar');
45
+ @include meta.load-css('../_sass/_content');
46
+ @include meta.load-css('../_sass/_types');
47
+ @include meta.load-css('../_sass/_mobile');
48
+ @include meta.load-css('../_sass/_api-box');
49
+ @include meta.load-css('../_sass/_syntax');
50
+ @include meta.load-css('../_sass/_deprecations');
@@ -1,19 +1,3 @@
1
1
  <h1><%= type[:name] %></h1>
2
2
 
3
3
  <%= type[:description] %>
4
-
5
- <% unless type[:connections].empty? %>
6
-
7
- <h2>Connections</h2>
8
-
9
- <%= include.('connections.html', connections: type[:connections]) %>
10
-
11
- <% end %>
12
-
13
- <% unless type[:fields].empty? %>
14
-
15
- <h2>Fields</h2>
16
-
17
- <%= include.('fields.html', fields: type[:fields]) %>
18
-
19
- <% end %>
@@ -0,0 +1,22 @@
1
+ <h1><%= type[:name] %></h1>
2
+
3
+ <%= include.('notices.html', notices: type[:notices]) %>
4
+
5
+ <%= type[:description] %>
6
+
7
+ <% if !type[:arguments].empty? %>
8
+
9
+ <h2>Arguments</h2>
10
+
11
+ <%= include.('fields.html', fields: type[:arguments]) %>
12
+
13
+ <% end %>
14
+
15
+
16
+ <% if !type[:return_fields].empty? %>
17
+
18
+ <h2>Return fields</h2>
19
+
20
+ <%= include.('fields.html', fields: type[:return_fields]) %>
21
+
22
+ <% end %>
@@ -7,7 +7,7 @@
7
7
  </li>
8
8
 
9
9
  <li>
10
- <p>Queries</p>
10
+ <p>Operations</p>
11
11
  <ul class="menu-root">
12
12
  <li>
13
13
  <a href="<%= base_url %>/operation/query/" class="sidebar-link<% if title == "Query" %> current<% end %>">
@@ -23,12 +23,12 @@
23
23
  </li>
24
24
 
25
25
  <li>
26
- <p><a href="<%= base_url %>/object">Objects</a></p>
26
+ <p><a href="<%= base_url %>/operation/query">Queries</a></p>
27
27
  <ul class="menu-root">
28
- <% graphql_object_types.().each do |type| %>
29
- <% @name = type[:name] %>
28
+ <% graphql_query_types.().each do |type| %>
29
+ <% @name = type[:name] %>
30
30
  <li>
31
- <a href="<%= base_url %>/object/<%= @name.downcase %>/" class="sidebar-link<% if title == @name %> current<% end %>">
31
+ <a href="<%= base_url %>/query/<%= @name.downcase %>/" class="sidebar-link<% if title == @name %> current<% end %>">
32
32
  <%= @name %>
33
33
  </a>
34
34
  </li>
@@ -50,6 +50,20 @@
50
50
  </ul>
51
51
  </li>
52
52
 
53
+ <li>
54
+ <p><a href="<%= base_url %>/object">Objects</a></p>
55
+ <ul class="menu-root">
56
+ <% graphql_object_types.().each do |type| %>
57
+ <% @name = type[:name] %>
58
+ <li>
59
+ <a href="<%= base_url %>/object/<%= @name.downcase %>/" class="sidebar-link<% if title == @name %> current<% end %>">
60
+ <%= @name %>
61
+ </a>
62
+ </li>
63
+ <% end %>
64
+ </ul>
65
+ </li>
66
+
53
67
  <li>
54
68
  <p><a href="<%= base_url %>/interface">Interfaces</a></p>
55
69
  <ul class="menu-root">
@@ -21,6 +21,7 @@ module GraphQLDocs
21
21
 
22
22
  @processed_schema = {
23
23
  operation_types: [],
24
+ query_types: [],
24
25
  mutation_types: [],
25
26
  object_types: [],
26
27
  interface_types: [],
@@ -51,8 +52,25 @@ module GraphQLDocs
51
52
  if data[:name] == root_types['query']
52
53
  data[:interfaces] = object.interfaces.map(&:graphql_name).sort
53
54
  data[:fields], data[:connections] = fetch_fields(object.fields, object.graphql_name)
54
-
55
55
  @processed_schema[:operation_types] << data
56
+
57
+ object.fields.each_value do |query|
58
+ h = {}
59
+
60
+ h[:notices] = @options[:notices].call([object.graphql_name, query.graphql_name].join('.'))
61
+ h[:name] = query.graphql_name
62
+ h[:description] = query.description
63
+ h[:arguments], = fetch_fields(query.arguments, [object.graphql_name, query.graphql_name].join('.'))
64
+
65
+ return_type = query.type
66
+ if return_type.unwrap.respond_to?(:fields)
67
+ h[:return_fields], = fetch_fields(return_type.unwrap.fields, return_type.graphql_name)
68
+ else # it is a scalar return type
69
+ h[:return_fields], = fetch_fields({ return_type.graphql_name => query }, return_type.graphql_name)
70
+ end
71
+
72
+ @processed_schema[:query_types] << h
73
+ end
56
74
  elsif data[:name] == root_types['mutation']
57
75
  @processed_schema[:operation_types] << data
58
76
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphQLDocs
4
- VERSION = '5.0.0'
4
+ VERSION = '5.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Chalupa
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-07-03 00:00:00.000000000 Z
12
+ date: 2024-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql
@@ -121,6 +121,34 @@ dependencies:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
123
  version: '1.58'
124
+ - !ruby/object:Gem::Dependency
125
+ name: ostruct
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '0.6'
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.6'
138
+ - !ruby/object:Gem::Dependency
139
+ name: logger
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '1.6'
145
+ type: :runtime
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '1.6'
124
152
  - !ruby/object:Gem::Dependency
125
153
  name: html-proofer
126
154
  requirement: !ruby/object:Gem::Requirement
@@ -141,14 +169,14 @@ dependencies:
141
169
  requirements:
142
170
  - - "~>"
143
171
  - !ruby/object:Gem::Version
144
- version: '5.0'
172
+ version: '5.24'
145
173
  type: :development
146
174
  prerelease: false
147
175
  version_requirements: !ruby/object:Gem::Requirement
148
176
  requirements:
149
177
  - - "~>"
150
178
  - !ruby/object:Gem::Version
151
- version: '5.0'
179
+ version: '5.24'
152
180
  - !ruby/object:Gem::Dependency
153
181
  name: minitest-focus
154
182
  requirement: !ruby/object:Gem::Requirement
@@ -318,6 +346,7 @@ files:
318
346
  - lib/graphql-docs/layouts/graphql_mutations.html
319
347
  - lib/graphql-docs/layouts/graphql_objects.html
320
348
  - lib/graphql-docs/layouts/graphql_operations.html
349
+ - lib/graphql-docs/layouts/graphql_queries.html
321
350
  - lib/graphql-docs/layouts/graphql_scalars.html
322
351
  - lib/graphql-docs/layouts/graphql_unions.html
323
352
  - lib/graphql-docs/layouts/includes/arguments.html
@@ -355,7 +384,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
384
  - !ruby/object:Gem::Version
356
385
  version: '0'
357
386
  requirements: []
358
- rubygems_version: 3.5.7
387
+ rubygems_version: 3.5.16
359
388
  signing_key:
360
389
  specification_version: 4
361
390
  summary: Easily generate beautiful documentation from your GraphQL schema.