forked from fragment-dev/fragment-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
33 lines (27 loc) · 836 Bytes
/
Rakefile
File metadata and controls
33 lines (27 loc) · 836 Bytes
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
# frozen_string_literal: true
require 'rake'
require 'rake/testtask'
require 'http'
require 'graphql'
require 'json'
Rake::TestTask.new do |t|
t.warning = false
t.libs << 'test'
t.test_files = FileList['test/*_test.rb']
end
task default: :test
namespace :graphql do
desc 'Download and convert GraphQL schema to JSON'
task :update_schema do
schema_url = 'https://api.us-west-2.fragment.dev/schema.graphql'
schema_path = 'lib/fragment.schema.json'
response = HTTP.get(schema_url)
schema = GraphQL::Schema.from_definition(response.to_s)
introspection_result = GraphQL::Introspection::INTROSPECTION_QUERY
query_result = schema.execute(introspection_result)
json_schema = JSON.pretty_generate(query_result)
File.open(schema_path, 'w') do |file|
file.write(json_schema)
end
end
end