Class: Mj::GraphQL::Request
- Inherits:
-
Object
- Object
- Mj::GraphQL::Request
- Defined in:
- lib/mj/graphql/request.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(endpoint: nil, query: nil, variables: {}, headers: {}) ⇒ Request
constructor
A new instance of Request.
- #to_h ⇒ Object
- #with_header(name, value) ⇒ Object
- #with_variables(variables) ⇒ Object
Constructor Details
#initialize(endpoint: nil, query: nil, variables: {}, headers: {}) ⇒ Request
Returns a new instance of Request.
8 9 10 11 12 13 |
# File 'lib/mj/graphql/request.rb', line 8 def initialize(endpoint: nil, query: nil, variables: {}, headers: {}) @endpoint = endpoint @query = query @variables = variables @headers = headers end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/mj/graphql/request.rb', line 6 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/mj/graphql/request.rb', line 6 def headers @headers end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
6 7 8 |
# File 'lib/mj/graphql/request.rb', line 6 def query @query end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
6 7 8 |
# File 'lib/mj/graphql/request.rb', line 6 def variables @variables end |
Instance Method Details
#to_h ⇒ Object
23 24 25 26 27 28 |
# File 'lib/mj/graphql/request.rb', line 23 def to_h { query: query, variables: variables } end |
#with_header(name, value) ⇒ Object
15 16 17 |
# File 'lib/mj/graphql/request.rb', line 15 def with_header(name, value) with(:headers, headers.merge(name => value)) end |
#with_variables(variables) ⇒ Object
19 20 21 |
# File 'lib/mj/graphql/request.rb', line 19 def with_variables(variables) with(:variables, variables) end |