graphql-docs 0.6.2 → 1.0.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -37
  3. data/Rakefile +15 -3
  4. data/graphql-docs.gemspec +0 -1
  5. data/lib/graphql-docs.rb +24 -10
  6. data/lib/graphql-docs/configuration.rb +5 -7
  7. data/lib/graphql-docs/generator.rb +31 -34
  8. data/lib/graphql-docs/helpers.rb +12 -63
  9. data/lib/graphql-docs/layouts/assets/_sass/_content.scss +22 -0
  10. data/lib/graphql-docs/layouts/assets/_sass/_deprecations.scss +9 -0
  11. data/lib/graphql-docs/layouts/assets/css/screen.scss +1 -0
  12. data/lib/graphql-docs/layouts/graphql_enums.html +4 -4
  13. data/lib/graphql-docs/layouts/graphql_input_objects.html +5 -5
  14. data/lib/graphql-docs/layouts/graphql_interfaces.html +17 -5
  15. data/lib/graphql-docs/layouts/graphql_mutations.html +14 -6
  16. data/lib/graphql-docs/layouts/graphql_objects.html +12 -12
  17. data/lib/graphql-docs/layouts/graphql_operation.html +19 -0
  18. data/lib/graphql-docs/layouts/graphql_scalars.html +2 -2
  19. data/lib/graphql-docs/layouts/graphql_unions.html +4 -4
  20. data/lib/graphql-docs/layouts/includes/arguments.html +3 -6
  21. data/lib/graphql-docs/layouts/includes/connections.html +4 -4
  22. data/lib/graphql-docs/layouts/includes/fields.html +16 -20
  23. data/lib/graphql-docs/layouts/includes/input_fields.html +5 -9
  24. data/lib/graphql-docs/layouts/includes/possible_types.html +1 -1
  25. data/lib/graphql-docs/layouts/includes/sidebar.html +10 -26
  26. data/lib/graphql-docs/layouts/includes/values.html +9 -2
  27. data/lib/graphql-docs/parser.rb +174 -29
  28. data/lib/graphql-docs/version.rb +1 -1
  29. metadata +6 -20
  30. data/lib/graphql-docs/client.rb +0 -55
  31. data/lib/graphql-docs/layouts/assets/_sass/screen.scss +0 -647
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2ecb384368186912ae4330f6d725e143e00ce45
4
- data.tar.gz: 37f6ff42e7f5c62eb036de963aae0f2f1d743a50
3
+ metadata.gz: d57299436da71122f707b8566d5c3866817206c9
4
+ data.tar.gz: f3d9e7e6c3f01a7720211bcbee87d1a26da2bb9c
5
5
  SHA512:
6
- metadata.gz: 2dc4a7f5d016cae84c3017d5ef90c3c5c64a4273e6b7105f68cc3ff108537fc9f9222ce1da662da2de0cc638c0e313ee6fb706ab1091f9889a2f7a1f7090de8f
7
- data.tar.gz: 5b707908d83d74f848e5efcc155d1fea2f2efce5607284b416e222cbdbde8472420ae6f4c966afa025368fdc793e4c2f38f96da806e5c43b3c839f98dc5ddcbd
6
+ metadata.gz: d77c30246e5dfe9a3a54243e08549b73e8b32ad933d78a39da04db84a69a8869fc074dfbcc677b1bd438792732d2f08fb1c7b9058593ac227ed340fde0d87975
7
+ data.tar.gz: c9b376846e30727006fb5282061e105ae9c28cf5f3659aec7389444cba5b87e4b28b92f1e7437c70996265b6c4d23c80198dae4518a113cf72ba9389bb519711
data/README.md CHANGED
@@ -22,56 +22,34 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- Simple! Call `GraphQLDocs.generate`, taking care to pass in the GraphQL endpoint:
26
-
27
- ``` ruby
28
- GraphQLDocs.build(url: 'http://graphql.org/swapi-graphql/')
29
- ```
30
-
31
- If your GraphQL endpoint requires authentication, you can provide a username or password, or an access token:
32
-
33
25
  ``` ruby
34
- options = {
35
- url: 'http://graphql.org/swapi-graphql/'
36
- login: 'gjtorikian',
37
- password: 'lolnowai'
38
- }
39
- GraphQLDocs.build(options)
26
+ # pass in a filename
27
+ GraphQLDocs.build(filename: filename)
40
28
 
41
- options = {
42
- url: 'http://graphql.org/swapi-graphql/'
43
- access_token: 'something123'
44
- }
45
-
46
- GraphQLDocs.build(options)
47
- ```
48
-
49
- If you already have the JSON locally, great! Call the same method with `path` instead:
50
-
51
- ``` ruby
52
- GraphQLDocs.build(path: 'location/to/sw-api.json')
29
+ # or pass in a string
30
+ GraphQLDocs.build(schema: contents)
53
31
  ```
54
32
 
55
33
  ## Breakdown
56
34
 
57
- There are several phases going on in one little `GraphQLDocs.build` call:
35
+ There are several phases going on the single `GraphQLDocs.build` call:
58
36
 
59
- * The GraphQL JSON is _fetched_ (if you passed `url`) through `GraphQL::Client` (or simply read if you passed `path`).
60
- * `GraphQL::Parser` manipulates that JSON into a slightly saner format.
61
- * `GraphQL::Generator` takes that JSON and converts it into HTML.
37
+ * The GraphQL IDL file is read (if you passed `filename`) through `GraphQL::Client` (or simply read if you passed a string through `schema`).
38
+ * `GraphQL::Parser` manipulates the IDL into a slightly saner format.
39
+ * `GraphQL::Generator` takes that saner format and converts it into HTML.
62
40
  * `GraphQL::Renderer` technically runs as part of the generation phase. It passes the contents of each page through a Markdown renderer.
63
41
 
64
42
  If you wanted to, you could break these calls up individually. For example:
65
43
 
66
44
  ``` ruby
67
45
  options = {}
68
- options[:path] = "#{File.dirname(__FILE__)}/../data/graphql/docs.json"
46
+ options[:filename] = "#{File.dirname(__FILE__)}/../data/graphql/schema.idl"
69
47
  my_renderer = MySuperCoolRenderer(options)
70
48
  options[:renderer] = my_renderer
71
49
 
72
50
  options = GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS.merge(options)
73
51
 
74
- response = File.read(options[:path])
52
+ response = File.read(options[:filename])
75
53
 
76
54
  parser = GraphQLDocs::Parser.new(response, options)
77
55
  parsed_schema = parser.parse
@@ -99,7 +77,7 @@ class CustomRenderer
99
77
  end
100
78
  end
101
79
 
102
- options[:path] = 'location/to/sw-api.json'
80
+ options[:filename] = 'location/to/sw-api.graphql'
103
81
  options[:renderer] = CustomRenderer
104
82
 
105
83
  GraphQLDocs.build(options)
@@ -112,8 +90,7 @@ In your ERB layouts, there are several helper methods you can use. The helper me
112
90
  * `slugify(str)` - This slugifies the given string.
113
91
  * `include(filename, opts)` - This embeds a template from your `includes` folder, passing along the local options provided.
114
92
  * `markdown(string)` - This converts a string from Markdown to HTML.
115
- * `format_type(field)` - This formats a type into an IDL-like representation. For example: `!Blah` or `[!Foo]`.
116
- * `graphql_mutation_types`, `graphql_object_types`, `graphql_interface_types`, `graphql_enum_types`, `graphql_union_types`, `graphql_input_object_types`, `graphql_scalar_types` - Collections of the various GraphQL types.
93
+ * `graphql_operation_types`, `graphql_mutation_types`, `graphql_object_types`, `graphql_interface_types`, `graphql_enum_types`, `graphql_union_types`, `graphql_input_object_types`, `graphql_scalar_types` - Collections of the various GraphQL types.
117
94
 
118
95
  To call these methods within templates, you must use the dot notation, such as `<%= slugify.(text) %>`.
119
96
 
@@ -131,11 +108,11 @@ The following options are available:
131
108
  | `url` | `GraphQLDocs::Client` makes a `POST` request to this URL, passing along the introspection query. | `nil` |
132
109
  | `output_dir` | The location of the output HTML. | `./output/` |
133
110
  | `use_default_styles` | Indicates if you want to use the default styles. | `true` |
134
- | `base_url` | Indicates the base URL to prepend for assets and links. | `true` |
111
+ | `base_url` | Indicates the base URL to prepend for assets and links. | `""` |
135
112
  | `delete_output` | Deletes `output_dir` before generating content. | `false` |
136
113
  | `pipeline_config` | Defines two sub-keys, `pipeline` and `context`, which are used by `html-pipeline` when rendering your output. | `pipeline` has `ExtendedMarkdownFilter`, `EmojiFilter`, and `TableOfContentsFilter`. `context` has `gfm: false` and `asset_root` set to GitHub's CDN. |
137
114
  | `renderer` | The rendering class to use. | `GraphQLDocs::Renderer`
138
- | `templates` | The templates to use when generating HTML. You may override any of the following keys: `default`, `includes`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`. | The defaults are found in _lib/graphql-docs/layouts/_.
115
+ | `templates` | The templates to use when generating HTML. You may override any of the following keys: `default`, `includes`, `operations`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`. | The defaults are found in _lib/graphql-docs/layouts/_.
139
116
  | `landing_pages` | The landing page to use when generating HTML for each type. You may override any of the following keys: `index`, `query`, `object`, `mutation`, `interface`, `enum`, `union`, `input_object`, `scalar`. | The defaults are found in _lib/graphql-docs/layouts/_.
140
117
  | `classes` | Additional class names you can provide to certain elements. | The full list is found in _lib/graphql-docs/configuration.rb/_.
141
118
 
data/Rakefile CHANGED
@@ -8,11 +8,23 @@ RuboCop::RakeTask.new(:rubocop)
8
8
  Rake::TestTask.new(:test) do |t|
9
9
  t.libs << 'test'
10
10
  t.libs << 'lib'
11
+ t.warning = false
11
12
  t.test_files = FileList['test/**/*_test.rb']
12
13
  end
13
14
 
14
15
  task default: :test
15
16
 
17
+ Rake::Task[:test].enhance { Rake::Task[:html_proofer].invoke }
18
+
19
+ desc 'Invoke HTML-Proofer'
20
+ task html_proofer: [:generate_sample] do
21
+ require 'html-proofer'
22
+ output_dir = File.join(File.dirname(__FILE__), 'output')
23
+
24
+ proofer_options = { disable_external: true, assume_extension: true }
25
+ HTMLProofer.check_directory(output_dir, proofer_options).run
26
+ end
27
+
16
28
  desc 'Set up a console'
17
29
  task :console do
18
30
  require 'pry'
@@ -28,13 +40,13 @@ task :console do
28
40
  end
29
41
 
30
42
  desc 'Generate the documentation'
31
- task :generate_sample, [:base_url] do |task, args|
43
+ task :generate_sample do
44
+ require 'pry'
32
45
  require 'graphql-docs'
33
46
 
34
47
  options = {}
35
48
  options[:delete_output] = true
36
- options[:base_url] = args.base_url || ''
37
- options[:path] = File.join(File.dirname(__FILE__), 'test', 'graphql-docs', 'fixtures', 'gh-api.json')
49
+ options[:filename] = File.join(File.dirname(__FILE__), 'test', 'graphql-docs', 'fixtures', 'gh-schema.graphql')
38
50
 
39
51
  GraphQLDocs.build(options)
40
52
  end
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency 'faraday', '< 0.10'#'~> 0.9'
24
23
  spec.add_dependency 'graphql', '~> 1.4'
25
24
 
26
25
  # rendering
@@ -1,5 +1,4 @@
1
1
  # rubocop:disable Style/FileName
2
- require 'graphql-docs/client'
3
2
  require 'graphql-docs/helpers'
4
3
  require 'graphql-docs/renderer'
5
4
  require 'graphql-docs/configuration'
@@ -9,6 +8,7 @@ require 'graphql-docs/version'
9
8
 
10
9
  begin
11
10
  require 'awesome_print'
11
+ require 'pry'
12
12
  rescue LoadError; end
13
13
 
14
14
  module GraphQLDocs
@@ -16,22 +16,36 @@ module GraphQLDocs
16
16
  def build(options)
17
17
  options = GraphQLDocs::Configuration::GRAPHQLDOCS_DEFAULTS.merge(options)
18
18
 
19
- if options[:url].nil? && options[:path].nil?
20
- fail ArgumentError, 'No :url or :path provided!'
19
+ filename = options[:filename]
20
+ schema = options[:schema]
21
+
22
+ if !filename.nil? && !schema.nil?
23
+ raise ArgumentError, 'Pass in `filename` or `schema`, but not both!'
21
24
  end
22
25
 
23
- if !options[:url].nil? && !options[:path].nil?
24
- fail ArgumentError, 'You can\'t pass both :url and :path!'
26
+ if filename.nil? && schema.nil?
27
+ raise ArgumentError, 'Pass in either `filename` or `schema`'
25
28
  end
26
29
 
27
- if options[:url]
28
- client = GraphQLDocs::Client.new(options)
29
- response = client.fetch
30
+ if filename
31
+ unless filename.is_a?(String)
32
+ raise TypeError, "Expected `String`, got `#{filename.class}`"
33
+ end
34
+
35
+ unless File.exist?(filename)
36
+ raise ArgumentError, "#{filename} does not exist!"
37
+ end
38
+
39
+ schema = File.read(filename)
30
40
  else
31
- response = File.read(options[:path])
41
+ unless schema.is_a?(String)
42
+ raise TypeError, "Expected `String`, got `#{schema.class}`"
43
+ end
44
+
45
+ schema = schema
32
46
  end
33
47
 
34
- parser = GraphQLDocs::Parser.new(response, options)
48
+ parser = GraphQLDocs::Parser.new(schema, options)
35
49
  parsed_schema = parser.parse
36
50
 
37
51
  generator = GraphQLDocs::Generator.new(parsed_schema, options)
@@ -1,13 +1,9 @@
1
1
  module GraphQLDocs
2
2
  module Configuration
3
3
  GRAPHQLDOCS_DEFAULTS = {
4
- # Client
5
- access_token: nil,
6
- headers: {},
7
- login: nil,
8
- password: nil,
9
- path: nil,
10
- url: nil,
4
+ # initialize
5
+ filename: nil,
6
+ schema: nil,
11
7
 
12
8
  # Generating
13
9
  delete_output: false,
@@ -30,6 +26,8 @@ module GraphQLDocs
30
26
  default: "#{File.dirname(__FILE__)}/layouts/default.html",
31
27
 
32
28
  includes: "#{File.dirname(__FILE__)}/layouts/includes",
29
+
30
+ operation: "#{File.dirname(__FILE__)}/layouts/graphql_operation.html",
33
31
  objects: "#{File.dirname(__FILE__)}/layouts/graphql_objects.html",
34
32
  mutations: "#{File.dirname(__FILE__)}/layouts/graphql_mutations.html",
35
33
  interfaces: "#{File.dirname(__FILE__)}/layouts/graphql_interfaces.html",
@@ -13,6 +13,7 @@ module GraphQLDocs
13
13
 
14
14
  @renderer = @options[:renderer].new(@options, @parsed_schema)
15
15
 
16
+ @graphql_operation_template = ERB.new(File.read(@options[:templates][:operation]))
16
17
  @graphql_object_template = ERB.new(File.read(@options[:templates][:objects]))
17
18
  @graphql_mutations_template = ERB.new(File.read(@options[:templates][:mutations]))
18
19
  @graphql_interfaces_template = ERB.new(File.read(@options[:templates][:interfaces]))
@@ -25,6 +26,7 @@ module GraphQLDocs
25
26
  def generate
26
27
  FileUtils.rm_rf(@options[:output_dir]) if @options[:delete_output]
27
28
 
29
+ create_graphql_operation_pages
28
30
  create_graphql_object_pages
29
31
  create_graphql_mutation_pages
30
32
  create_graphql_interface_pages
@@ -42,7 +44,7 @@ module GraphQLDocs
42
44
  end
43
45
 
44
46
  unless @options[:landing_pages][:mutation].nil?
45
- write_file('static', 'mutation', File.read(@options[:landing_pages][:mutation]))
47
+ write_file('operation', 'mutation', File.read(@options[:landing_pages][:mutation]))
46
48
  end
47
49
 
48
50
  unless @options[:landing_pages][:interface].nil?
@@ -79,14 +81,10 @@ module GraphQLDocs
79
81
  true
80
82
  end
81
83
 
82
- def create_graphql_object_pages
83
- graphql_object_types.each do |object_type|
84
- next if object_type['name'].start_with?('__')
85
- if object_type['name'] == 'Mutation'
86
- next unless @options[:landing_pages][:mutation].nil?
87
- end
88
- if object_type['name'] == 'Query'
89
- metadata = ''
84
+ def create_graphql_operation_pages
85
+ graphql_operation_types.each do |query_type|
86
+ metadata = ''
87
+ if query_type[:name] == 'Query'
90
88
  unless @options[:landing_pages][:query].nil?
91
89
  query_landing_page = @options[:landing_pages][:query]
92
90
  query_landing_page = File.read(query_landing_page)
@@ -98,75 +96,74 @@ module GraphQLDocs
98
96
  metadata = pieces[1, 3].join("\n")
99
97
  query_landing_page = pieces[4]
100
98
  end
101
- object_type['description'] = query_landing_page
99
+ query_type[:description] = query_landing_page
102
100
  end
103
- opts = default_generator_options(type: object_type)
104
- contents = @graphql_object_template.result(OpenStruct.new(opts).instance_eval { binding })
105
- write_file('static', 'query', metadata + contents)
106
- else
107
- opts = default_generator_options(type: object_type)
108
- contents = @graphql_object_template.result(OpenStruct.new(opts).instance_eval { binding })
109
- write_file('object', object_type['name'], contents)
101
+ opts = default_generator_options(type: query_type)
102
+ contents = @graphql_operation_template.result(OpenStruct.new(opts).instance_eval { binding })
103
+ write_file('operation', query_type[:name], metadata + contents)
110
104
  end
111
105
  end
112
106
  end
113
107
 
108
+ def create_graphql_object_pages
109
+ graphql_object_types.each do |object_type|
110
+ opts = default_generator_options(type: object_type)
111
+ contents = @graphql_object_template.result(OpenStruct.new(opts).instance_eval { binding })
112
+ write_file('object', object_type[:name], contents)
113
+ end
114
+ end
115
+
114
116
  def create_graphql_mutation_pages
115
117
  graphql_mutation_types.each do |mutation|
116
- input_name = mutation['args'].first['type']['ofType']['name']
117
- return_name = mutation['type']['name']
118
- input = graphql_input_object_types.find { |t| t['name'] == input_name }
119
- payload = graphql_object_types.find { |t| t['name'] == return_name }
120
-
121
- opts = default_generator_options({ type: mutation, input_fields: input, return_fields: payload })
118
+ opts = default_generator_options(type: mutation)
122
119
 
123
120
  contents = @graphql_mutations_template.result(OpenStruct.new(opts).instance_eval { binding })
124
- write_file('mutation', mutation['name'], contents)
121
+ write_file('mutation', mutation[:name], contents)
125
122
  end
126
123
  end
127
124
 
128
125
  def create_graphql_interface_pages
129
126
  graphql_interface_types.each do |interface_type|
130
- opts = default_generator_options({ type: interface_type })
127
+ opts = default_generator_options(type: interface_type)
131
128
 
132
129
  contents = @graphql_interfaces_template.result(OpenStruct.new(opts).instance_eval { binding })
133
- write_file('interface', interface_type['name'], contents)
130
+ write_file('interface', interface_type[:name], contents)
134
131
  end
135
132
  end
136
133
 
137
134
  def create_graphql_enum_pages
138
135
  graphql_enum_types.each do |enum_type|
139
- opts = default_generator_options({ type: enum_type })
136
+ opts = default_generator_options(type: enum_type)
140
137
 
141
138
  contents = @graphql_enums_template.result(OpenStruct.new(opts).instance_eval { binding })
142
- write_file('enum', enum_type['name'], contents)
139
+ write_file('enum', enum_type[:name], contents)
143
140
  end
144
141
  end
145
142
 
146
143
  def create_graphql_union_pages
147
144
  graphql_union_types.each do |union_type|
148
- opts = default_generator_options({ type: union_type })
145
+ opts = default_generator_options(type: union_type)
149
146
 
150
147
  contents = @graphql_unions_template.result(OpenStruct.new(opts).instance_eval { binding })
151
- write_file('union', union_type['name'], contents)
148
+ write_file('union', union_type[:name], contents)
152
149
  end
153
150
  end
154
151
 
155
152
  def create_graphql_input_object_pages
156
153
  graphql_input_object_types.each do |input_object_type|
157
- opts = default_generator_options({ type: input_object_type })
154
+ opts = default_generator_options(type: input_object_type)
158
155
 
159
156
  contents = @graphql_input_objects_template.result(OpenStruct.new(opts).instance_eval { binding })
160
- write_file('input_object', input_object_type['name'], contents)
157
+ write_file('input_object', input_object_type[:name], contents)
161
158
  end
162
159
  end
163
160
 
164
161
  def create_graphql_scalar_pages
165
162
  graphql_scalar_types.each do |scalar_type|
166
- opts = default_generator_options({ type: scalar_type })
163
+ opts = default_generator_options(type: scalar_type)
167
164
 
168
165
  contents = @graphql_scalars_template.result(OpenStruct.new(opts).instance_eval { binding })
169
- write_file('scalar', scalar_type['name'], contents)
166
+ write_file('scalar', scalar_type[:name], contents)
170
167
  end
171
168
  end
172
169
 
@@ -1,3 +1,5 @@
1
+ require 'commonmarker'
2
+
1
3
  module GraphQLDocs
2
4
  module Helpers
3
5
  SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
@@ -18,92 +20,39 @@ module GraphQLDocs
18
20
 
19
21
  def markdown(string)
20
22
  return '' if string.nil?
21
- CommonMarker.render_html(string, :DEFAULT)
23
+ ::CommonMarker.render_html(string, :DEFAULT)
22
24
  end
23
25
 
24
- # Do you think I am proud of this? I am not.
25
- def format_type(field)
26
- type_path = name_slug = nil
27
- type_name = ''
28
-
29
- if field['type']['kind'] == 'NON_NULL'
30
- if !field['type']['ofType']['ofType'].nil?
31
- # we're going to be a list...but what kind?!
32
- type_name << '['
33
- if !field['type']['ofType']['ofType']['ofType'].nil?
34
- type_path = field['type']['ofType']['ofType']['ofType']['kind']
35
- type_name << field['type']['ofType']['ofType']['ofType']['name']
36
- name_slug = field['type']['ofType']['ofType']['ofType']['name']
37
- # A required list of required items: [Blah!]!
38
- if field['type']['ofType']['ofType']['kind'] == 'NON_NULL'
39
- type_name << '!'
40
- end
41
- else
42
- # A required list of non-required items: [Blah]!
43
- type_path = field['type']['ofType']['ofType']['kind']
44
- type_name << field['type']['ofType']['ofType']['name']
45
- name_slug = field['type']['ofType']['ofType']['name']
46
- end
47
- type_name << ']'
48
- type_name << '!'
49
- else
50
- type_path = field['type']['ofType']['kind']
51
- type_name << field['type']['ofType']['name']
52
- name_slug = field['type']['ofType']['name']
53
- # Simple non-null item: Blah!
54
- type_name << '!'
55
- end
56
- elsif field['type']['kind'] == 'LIST'
57
- type_name << '['
58
- if field['type']['ofType']['kind'] == 'NON_NULL'
59
- type_path = field['type']['ofType']['ofType']['kind']
60
- type_name << field['type']['ofType']['ofType']['name']
61
- name_slug = field['type']['ofType']['ofType']['name']
62
- # Nullable list of non-null items: [Blah!]
63
- type_name << '!'
64
- else
65
- # Nullable list of nullable items: [Blah]
66
- type_path = field['type']['ofType']['kind']
67
- type_name << field['type']['ofType']['name']
68
- name_slug = field['type']['ofType']['name']
69
- end
70
- type_name << ']'
71
- else
72
- # Simple nullable item: Blah
73
- type_path = field['type']['kind']
74
- type_name << field['type']['name']
75
- name_slug = field['type']['name']
76
- end
77
-
78
- [type_path.downcase, type_name, name_slug.downcase]
26
+ def graphql_operation_types
27
+ @parsed_schema[:operation_types] || []
79
28
  end
80
29
 
81
30
  def graphql_mutation_types
82
- @parsed_schema['mutation_types'] || []
31
+ @parsed_schema[:mutation_types] || []
83
32
  end
84
33
 
85
34
  def graphql_object_types
86
- @parsed_schema['object_types'] || []
35
+ @parsed_schema[:object_types] || []
87
36
  end
88
37
 
89
38
  def graphql_interface_types
90
- @parsed_schema['interface_types'] || []
39
+ @parsed_schema[:interface_types] || []
91
40
  end
92
41
 
93
42
  def graphql_enum_types
94
- @parsed_schema['enum_types'] || []
43
+ @parsed_schema[:enum_types] || []
95
44
  end
96
45
 
97
46
  def graphql_union_types
98
- @parsed_schema['union_types'] || []
47
+ @parsed_schema[:union_types] || []
99
48
  end
100
49
 
101
50
  def graphql_input_object_types
102
- @parsed_schema['input_object_types'] || []
51
+ @parsed_schema[:input_object_types] || []
103
52
  end
104
53
 
105
54
  def graphql_scalar_types
106
- @parsed_schema['scalar_types'] || []
55
+ @parsed_schema[:scalar_types] || []
107
56
  end
108
57
 
109
58
  private