Class: GraphQL::RakeTask
- Inherits:
-
Object
- Object
- GraphQL::RakeTask
- Extended by:
- Rake::DSL
- Includes:
- Rake::DSL
- Defined in:
- lib/graphql/rake_task.rb,
lib/graphql/rake_task/validate.rb
Overview
A rake task for dumping a schema as IDL or JSON.
By default, schemas are looked up by name as constants using schema_name:
.
You can provide a load_schema
function to return your schema another way.
Use load_context:
and visible?
to dump schemas under certain visibility constraints.
Constant Summary collapse
- DEFAULT_OPTIONS =
{ namespace: "graphql", dependencies: nil, schema_name: nil, load_schema: ->(task) { Object.const_get(task.schema_name) }, load_context: ->(task) { {} }, directory: ".", idl_outfile: "schema.graphql", json_outfile: "schema.json", include_deprecated_args: true, include_schema_description: false, include_is_repeatable: false, include_specified_by_url: false, include_is_one_of: false }
Instance Attribute Summary collapse
- #dependencies ⇒ Array<String>
-
#directory ⇒ String
Directory for IDL & JSON files.
-
#idl_outfile ⇒ String
Target for IDL task.
-
#include_deprecated_args ⇒ Boolean
Options for additional fields in the introspection query JSON response.
-
#include_is_one_of ⇒ Boolean
Options for additional fields in the introspection query JSON response.
-
#include_is_repeatable ⇒ Boolean
Options for additional fields in the introspection query JSON response.
-
#include_schema_description ⇒ Boolean
Options for additional fields in the introspection query JSON response.
-
#include_specified_by_url ⇒ Boolean
Options for additional fields in the introspection query JSON response.
-
#json_outfile ⇒ String
Target for JSON task.
-
#load_context ⇒ <#call(task)>
A callable for loading the query context.
-
#load_schema ⇒ <#call(task)>
A proc for loading the target GraphQL schema.
-
#namespace ⇒ String
writeonly
Namespace for generated tasks.
-
#schema_name ⇒ String
By default, used to find the schema as a constant.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ RakeTask
constructor
Set the parameters of this task by passing keyword arguments or assigning attributes inside the block.
- #rake_namespace ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RakeTask
Set the parameters of this task by passing keyword arguments or assigning attributes inside the block
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/graphql/rake_task.rb', line 83 def initialize( = {}) = DEFAULT_OPTIONS.merge() .each do |k, v| self.public_send("#{k}=", v) end if block_given? yield(self) end define_task end |
Instance Attribute Details
#dependencies ⇒ Array<String>
56 57 58 |
# File 'lib/graphql/rake_task.rb', line 56 def dependencies @dependencies end |
#directory ⇒ String
Returns directory for IDL & JSON files.
75 76 77 |
# File 'lib/graphql/rake_task.rb', line 75 def directory @directory end |
#idl_outfile ⇒ String
Returns target for IDL task.
69 70 71 |
# File 'lib/graphql/rake_task.rb', line 69 def idl_outfile @idl_outfile end |
#include_deprecated_args ⇒ Boolean
Returns Options for additional fields in the introspection query JSON response.
79 80 81 |
# File 'lib/graphql/rake_task.rb', line 79 def include_deprecated_args @include_deprecated_args end |
#include_is_one_of ⇒ Boolean
Returns Options for additional fields in the introspection query JSON response.
79 80 81 |
# File 'lib/graphql/rake_task.rb', line 79 def include_is_one_of @include_is_one_of end |
#include_is_repeatable ⇒ Boolean
Returns Options for additional fields in the introspection query JSON response.
79 80 81 |
# File 'lib/graphql/rake_task.rb', line 79 def include_is_repeatable @include_is_repeatable end |
#include_schema_description ⇒ Boolean
Returns Options for additional fields in the introspection query JSON response.
79 80 81 |
# File 'lib/graphql/rake_task.rb', line 79 def include_schema_description @include_schema_description end |
#include_specified_by_url ⇒ Boolean
Returns Options for additional fields in the introspection query JSON response.
79 80 81 |
# File 'lib/graphql/rake_task.rb', line 79 def include_specified_by_url @include_specified_by_url end |
#json_outfile ⇒ String
Returns target for JSON task.
72 73 74 |
# File 'lib/graphql/rake_task.rb', line 72 def json_outfile @json_outfile end |
#load_context ⇒ <#call(task)>
Returns A callable for loading the query context.
66 67 68 |
# File 'lib/graphql/rake_task.rb', line 66 def load_context @load_context end |
#load_schema ⇒ <#call(task)>
Returns A proc for loading the target GraphQL schema.
63 64 65 |
# File 'lib/graphql/rake_task.rb', line 63 def load_schema @load_schema end |
#namespace=(value) ⇒ String (writeonly)
Returns Namespace for generated tasks.
49 50 51 |
# File 'lib/graphql/rake_task.rb', line 49 def namespace=(value) @namespace = value end |
#schema_name ⇒ String
Returns By default, used to find the schema as a constant.
60 61 62 |
# File 'lib/graphql/rake_task.rb', line 60 def schema_name @schema_name end |
Instance Method Details
#rake_namespace ⇒ Object
51 52 53 |
# File 'lib/graphql/rake_task.rb', line 51 def rake_namespace @namespace end |