Sha256: d9b1a318bb12317015f93554c7c16f14080fad670ee9e9eff4038a2a992c0b34

Contents?: true

Size: 822 Bytes

Versions: 10

Compression:

Stored size: 822 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Surveys
    SurveysType = GraphQL::ObjectType.define do
      interfaces [-> { Decidim::Core::ComponentInterface }]

      name "Surveys"
      description "A surveys component of a participatory space."

      connection :surveys, SurveyType.connection_type do
        resolve ->(component, _args, _ctx) {
                  SurveysTypeHelper.base_scope(component).includes(:component)
                }
      end

      field(:survey, SurveyType) do
        argument :id, !types.ID

        resolve ->(component, args, _ctx) {
          SurveysTypeHelper.base_scope(component).find_by(id: args[:id])
        }
      end
    end

    module SurveysTypeHelper
      def self.base_scope(component)
        Survey.where(component: component)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-surveys-0.23.6 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.23.5 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.23.4 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.23.3 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.23.2 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.23.1 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.23.1.rc1 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.23.0 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.22.0 app/types/decidim/surveys/surveys_type.rb
decidim-surveys-0.21.0 app/types/decidim/surveys/surveys_type.rb