-
Notifications
You must be signed in to change notification settings - Fork 18
/
Rakefile
58 lines (44 loc) · 1.45 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'solidus_dev_support/rake_tasks'
require 'graphql-docs'
SolidusDevSupport::RakeTasks.install
task default: 'extension:specs'
namespace :schema do
desc 'Generates documentation from schema.graphql'
task :generate_docs do
doc_dir = "./lib/graphql_docs"
GraphQLDocs.build(
filename: "#{__dir__}/schema.graphql",
output_dir: 'docs',
base_url: '/solidus_graphql_api/docs',
landing_pages: { index: "#{doc_dir}/landing_pages/index.md" },
delete_output: true
)
end
desc 'Dump the schema to JSON and IDL and generate docs'
task :dump do
setup_graphql_rake_tasks
Rake::Task['graphql:schema:dump'].invoke
Rake::Task['schema:generate_docs'].invoke
end
desc 'Dump the schema to IDL in schema.graphql and generate docs'
task :idl do
setup_graphql_rake_tasks
Rake::Task['graphql:schema:idl'].invoke
Rake::Task['schema:generate_docs'].invoke
end
desc 'Dump the schema to JSON in schema.json and generate docs'
task :json do
setup_graphql_rake_tasks
Rake::Task['graphql:schema:json'].invoke
Rake::Task['schema:generate_docs'].invoke
end
end
private
def setup_graphql_rake_tasks
require 'graphql/rake_task'
GraphQL::RakeTask.new(schema_name: 'SolidusGraphqlApi::Schema')
Rake::Task['extension:test_app'].invoke if Dir['spec/dummy'].empty?
require File.expand_path('spec/dummy/config/environment.rb', __dir__)
end