Class: Ecoportal::API::GraphQL::Mutation::Template::UpdateRelatedPage

Inherits:
Logic::Mutation
  • Object
show all
Defined in:
lib/ecoportal/api/graphql/mutation/template/update_related_page.rb

Overview

updateRelatedPage(input: UpdateRelatedPageInput!) — edits an existing related-pages CONFIG entry on a template (title / target register / filters).

★ The worklog long carried this as an "ecoportal backend gap — the only genuine structural template omission". That note is STALE: the mutation exists in the live schema (verified 20260731), so the gap was ours. Without it, related-pages entries could be created and destroyed but never edited — every title or filter change meant destroy + recreate, which loses the entry id.

Note the argument name asymmetry, which is the schema's: create/destroy are createTemplateRelatedPage/destroyTemplateRelatedPage, but update is plain updateRelatedPage (no Template infix).

Constant Summary collapse

SCHEMA_VERSION =
'20260731'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Logic::Mutation

#response_class

Class Method Details

.build_input(template_id:, id:, patch_ver:, title: nil, register_id: nil, filters: nil) ⇒ Object

Extracted so the partial-update rule is testable without a client or a network stub. A nil optional key is OMITTED, not serialised as an explicit null — the server reads an absent key as "leave alone", so sending null would blank the stored value.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ecoportal/api/graphql/mutation/template/update_related_page.rb', line 45

def self.build_input(template_id:, id:, patch_ver:, title: nil, register_id: nil, filters: nil)
  {
    templateId: template_id,
    id:         id,
    patchVer:   patch_ver
  }.tap do |input|
    input[:title]      = title       unless title.nil?
    input[:registerId] = register_id unless register_id.nil?
    input[:filters]    = filters     unless filters.nil?
  end
end

Instance Method Details

#query(template_id:, id:, patch_ver:, title: nil, register_id: nil, filters: nil, **kargs, &block) ⇒ Object

Parameters:

  • template_id (String)

    the template page id.

  • id (String)

    the RelatedPages entry id being edited.

  • patch_ver (Integer)

    template patchVer (optimistic concurrency).

  • title (String, nil) (defaults to: nil)

    new title. Omitted when nil — the schema treats an absent key as "leave alone", so nil must NOT be sent as an explicit null.

  • register_id (String, nil) (defaults to: nil)

    retarget the entry at another register.

  • filters (Array<Hash>, nil) (defaults to: nil)

    [SearchFilter!]. Note SearchFilter.params is an untyped Hash in the schema, so its inner shape is not validated by GraphQL — callers must get it right themselves.



34
35
36
37
38
39
40
# File 'lib/ecoportal/api/graphql/mutation/template/update_related_page.rb', line 34

def query(template_id:, id:, patch_ver:, title: nil, register_id: nil, filters: nil, **kargs, &block)
  input = self.class.build_input(
    template_id: template_id, id: id, patch_ver: patch_ver,
    title: title, register_id: register_id, filters: filters
  )
  super(input: input, **kargs, &block)
end