Module: Ecoportal::API::GraphQL::Concerns::PageCompat

Included in:
Interface::BasePage
Defined in:
lib/ecoportal/api/graphql/concerns/page_compat.rb

Overview

v2-compatibility accessors for page model objects. Include in Interface::BasePage so all concrete page classes inherit them. These aliases allow eco-helpers scripts to work against GraphQL page models using the same method names they used with ecoportal-api-v2.

Instance Method Summary collapse

Instance Method Details

#componentsObject

v2 compatibility: dataFields were called "components" in APIv2



21
22
23
# File 'lib/ecoportal/api/graphql/concerns/page_compat.rb', line 21

def components
  respond_to?(:dataFields) ? dataFields : []
end

#consolidate!Object

Clears dirty tracking — call after a successful update. Mirrors v2's ooze.consolidate! which resets the change baseline.



32
33
34
35
# File 'lib/ecoportal/api/graphql/concerns/page_compat.rb', line 32

def consolidate!
  @original_doc = doc.dup if respond_to?(:doc)
  self
end

#dirty?Boolean

Dirty check — returns true if there are pending changes.

Returns:

  • (Boolean)


44
45
46
# File 'lib/ecoportal/api/graphql/concerns/page_compat.rb', line 44

def dirty?
  !as_update.nil?
end

#external_idObject

v2 called this externalId (camelCase) or external_id (snake_case)



11
12
13
# File 'lib/ecoportal/api/graphql/concerns/page_compat.rb', line 11

def external_id
  externalId
end

#stages?Boolean

Whether the page has any stages (PhasedPage check)

Returns:

  • (Boolean)


26
27
28
# File 'lib/ecoportal/api/graphql/concerns/page_compat.rb', line 26

def stages?
  respond_to?(:stages) && !stages.nil? && !stages.empty?
end

#template_idObject

v2 called sourceTemplateId "template_id"



16
17
18
# File 'lib/ecoportal/api/graphql/concerns/page_compat.rb', line 16

def template_id
  sourceTemplateId
end

#validateObject

v2 validate stub — always returns nil (no client-side validation in GraphQL path). Server-side errors are returned in the mutation payload's errors field.



39
40
41
# File 'lib/ecoportal/api/graphql/concerns/page_compat.rb', line 39

def validate
  nil
end