Sha256: 6be36fd122b485ddb861a661c73c34a91565526f383462a1431faefcf0531e3c
Contents?: true
Size: 876 Bytes
Versions: 8
Compression:
Stored size: 876 Bytes
Contents
# frozen_string_literal: true module Decidim module Elections ElectionsType = GraphQL::ObjectType.define do interfaces [-> { Decidim::Core::ComponentInterface }] name "Elections" description "An elections component of a participatory space." connection :elections, ElectionType.connection_type do resolve ->(component, _args, _ctx) { ElectionsTypeHelper.base_scope(component).includes(:component) } end field(:election, ElectionType) do argument :id, !types.ID resolve ->(component, args, _ctx) { ElectionsTypeHelper.base_scope(component).find_by(id: args[:id]) } end end module ElectionsTypeHelper def self.base_scope(component) Election.where(component: component).where.not(published_at: nil) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems