Class: Ecoportal::API::GraphQL::Compat::Response
- Inherits:
-
Object
- Object
- Ecoportal::API::GraphQL::Compat::Response
- Defined in:
- lib/ecoportal/api/graphql/compat/response.rb
Overview
Wraps a GraphQL mutation payload to expose the v2-compatible response interface. Scripts check .success? and .status after update/create operations.
Instance Method Summary collapse
- #body ⇒ Object
- #error? ⇒ Boolean
-
#initialize(payload) ⇒ Response
constructor
A new instance of Response.
- #item ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(payload) ⇒ Response
Returns a new instance of Response.
8 9 10 |
# File 'lib/ecoportal/api/graphql/compat/response.rb', line 8 def initialize(payload) @payload = payload end |
Instance Method Details
#body ⇒ Object
24 25 26 |
# File 'lib/ecoportal/api/graphql/compat/response.rb', line 24 def body @payload.error_doc end |
#error? ⇒ Boolean
16 17 18 |
# File 'lib/ecoportal/api/graphql/compat/response.rb', line 16 def error? @payload.error? end |
#item ⇒ Object
28 29 30 |
# File 'lib/ecoportal/api/graphql/compat/response.rb', line 28 def item @payload.item end |
#status ⇒ Object
20 21 22 |
# File 'lib/ecoportal/api/graphql/compat/response.rb', line 20 def status @payload.error? ? :error : :ok end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/ecoportal/api/graphql/compat/response.rb', line 12 def success? @payload.success? end |