Class: GraphQLPreview::SchemaModification
- Inherits:
-
Object
- Object
- GraphQLPreview::SchemaModification
- Defined in:
- lib/graphql-preview/schema_modification.rb
Constant Summary collapse
- DEFAULT_ENVIRONMENT =
:all
Class Method Summary collapse
- .announced_on(date, url: nil) ⇒ Object
- .announcement ⇒ Object
- .apply_to_schema(schema, possible_environments) ⇒ Object
- .description(new_description = nil) ⇒ Object
- .environments(*new_environments) ⇒ Object
- .title(new_title = nil) ⇒ Object
- .to_h ⇒ Object
- .toggled_by(new_toggled_by = nil) ⇒ Object
- .toggled_on(member_paths = nil) ⇒ Object
- .unset(schema) ⇒ Object
- .updated_on(date, url: nil) ⇒ Object
- .updates ⇒ Object
Class Method Details
.announced_on(date, url: nil) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/graphql-preview/schema_modification.rb', line 48 def self.announced_on(date, url: nil) @announcement = { date: date, url: url } end |
.announcement ⇒ Object
55 56 57 |
# File 'lib/graphql-preview/schema_modification.rb', line 55 def self.announcement @announcement end |
.apply_to_schema(schema, possible_environments) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/graphql-preview/schema_modification.rb', line 90 def self.apply_to_schema(schema, possible_environments) environments = if self.environments self.environments else possible_environments end value = Hash[environments.map{ |env| [env, self] }] set_preview_toggled_by_on_members(schema, value) end |
.description(new_description = nil) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/graphql-preview/schema_modification.rb', line 32 def self.description(new_description = nil) if new_description @description = new_description else @description end end |
.environments(*new_environments) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/graphql-preview/schema_modification.rb', line 5 def self.environments(*new_environments) if new_environments.length > 0 @environments = new_environments else @environments end end |
.title(new_title = nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/graphql-preview/schema_modification.rb', line 24 def self.title(new_title = nil) if new_title @title = new_title else @title end end |
.to_h ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/graphql-preview/schema_modification.rb', line 13 def self.to_h { title: title, description: description, toggled_by: toggled_by, announcement: announcement, updates: updates, toggled_on: toggled_on } end |
.toggled_by(new_toggled_by = nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/graphql-preview/schema_modification.rb', line 40 def self.toggled_by(new_toggled_by = nil) if new_toggled_by @toggled_by = new_toggled_by else @toggled_by end end |
.toggled_on(member_paths = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/graphql-preview/schema_modification.rb', line 72 def self.toggled_on(member_paths = nil) if member_paths member_paths.each do |path| unless path.is_a?(String) raise ArgumentError, "Provide string paths to `toggled_on`. For example, to toggle on a field called `name` on a type `Author`, use `\"Author.name\"``" end end @member_paths = member_paths else @member_paths end end |
.unset(schema) ⇒ Object
86 87 88 |
# File 'lib/graphql-preview/schema_modification.rb', line 86 def self.unset(schema) set_preview_toggled_by_on_members(schema, nil) end |
.updated_on(date, url: nil) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/graphql-preview/schema_modification.rb', line 59 def self.updated_on(date, url: nil) @updates ||= [] @updates << { date: date, url: url } end |
.updates ⇒ Object
68 69 70 |
# File 'lib/graphql-preview/schema_modification.rb', line 68 def self.updates @updates end |