Class: GraphQL::Client::Query
- Inherits:
-
Object
- Object
- GraphQL::Client::Query
- Defined in:
- lib/graphql/client.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#operation_name ⇒ Object
readonly
Returns the value of attribute operation_name.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(document, operation_name: nil, variables: {}, context: {}) ⇒ Query
constructor
A new instance of Query.
- #operation ⇒ Object
- #operation_type ⇒ Object
- #payload ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(document, operation_name: nil, variables: {}, context: {}) ⇒ Query
Returns a new instance of Query.
245 246 247 248 249 250 |
# File 'lib/graphql/client.rb', line 245 def initialize(document, operation_name: nil, variables: {}, context: {}) @document = document @operation_name = operation_name @variables = variables @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
243 244 245 |
# File 'lib/graphql/client.rb', line 243 def context @context end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
243 244 245 |
# File 'lib/graphql/client.rb', line 243 def document @document end |
#operation_name ⇒ Object (readonly)
Returns the value of attribute operation_name.
243 244 245 |
# File 'lib/graphql/client.rb', line 243 def operation_name @operation_name end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
243 244 245 |
# File 'lib/graphql/client.rb', line 243 def variables @variables end |
Instance Method Details
#operation ⇒ Object
256 257 258 |
# File 'lib/graphql/client.rb', line 256 def operation document.definitions.find { |node| node.name == operation_name } end |
#operation_type ⇒ Object
260 261 262 |
# File 'lib/graphql/client.rb', line 260 def operation_type operation.operation_type end |
#payload ⇒ Object
264 265 266 267 268 269 270 271 |
# File 'lib/graphql/client.rb', line 264 def payload { document: document, operation_name: operation_name, operation_type: operation_type, variables: variables } end |
#to_s ⇒ Object
252 253 254 |
# File 'lib/graphql/client.rb', line 252 def to_s document.to_query_string end |