Module: Decidim::Core
- Defined in:
- lib/decidim/core/version.rb,
lib/decidim/core/api.rb,
lib/decidim/core/engine.rb,
app/types/decidim/core/date_type.rb,
app/types/decidim/core/user_type.rb,
lib/decidim/api/author_interface.rb,
app/types/decidim/core/metric_type.rb,
lib/decidim/api/scopable_interface.rb,
app/types/decidim/core/decidim_type.rb,
app/types/decidim/core/hashtag_type.rb,
app/types/decidim/core/session_type.rb,
lib/decidim/api/amendable_interface.rb,
lib/decidim/api/component_interface.rb,
lib/decidim/api/traceable_interface.rb,
app/types/decidim/core/area_api_type.rb,
app/types/decidim/core/category_type.rb,
lib/decidim/api/attachable_interface.rb,
lib/decidim/api/authorable_interface.rb,
lib/decidim/api/endorsable_interface.rb,
lib/decidim/api/timestamps_interface.rb,
app/types/decidim/core/amendment_type.rb,
app/types/decidim/core/area_type_type.rb,
app/types/decidim/core/component_type.rb,
app/types/decidim/core/date_time_type.rb,
app/types/decidim/core/scope_api_type.rb,
app/types/decidim/core/statistic_type.rb,
lib/decidim/api/fingerprint_interface.rb,
app/types/decidim/core/attachment_type.rb,
app/types/decidim/core/base_input_sort.rb,
app/types/decidim/core/user_group_type.rb,
lib/decidim/api/coauthorable_interface.rb,
app/types/decidim/core/coordinates_type.rb,
app/types/decidim/core/fingerprint_type.rb,
lib/decidim/api/categorizable_interface.rb,
app/types/decidim/core/base_input_filter.rb,
app/types/decidim/core/organization_type.rb,
app/functions/decidim/core/component_list.rb,
app/types/decidim/core/trace_version_type.rb,
app/resolvers/decidim/core/metric_resolver.rb,
app/types/decidim/core/metric_history_type.rb,
lib/decidim/api/amendable_entity_interface.rb,
app/functions/decidim/core/user_entity_list.rb,
app/types/decidim/core/component_input_sort.rb,
app/types/decidim/core/localized_string_type.rb,
app/types/decidim/core/translated_field_type.rb,
app/functions/decidim/core/user_entity_finder.rb,
app/types/decidim/core/component_input_filter.rb,
app/types/decidim/core/user_entity_input_sort.rb,
lib/decidim/api/participatory_space_interface.rb,
app/functions/decidim/core/component_list_base.rb,
app/types/decidim/core/has_localized_input_sort.rb,
app/types/decidim/core/has_timestamp_input_sort.rb,
app/types/decidim/core/participatory_space_type.rb,
app/types/decidim/core/user_entity_input_filter.rb,
app/functions/decidim/core/component_finder_base.rb,
app/types/decidim/core/has_endorsable_input_sort.rb,
app/types/decidim/core/has_localized_input_filter.rb,
app/types/decidim/core/has_publishable_input_sort.rb,
app/types/decidim/core/has_timestamp_input_filter.rb,
app/functions/decidim/core/participatory_space_list.rb,
app/types/decidim/core/has_hastaggable_input_filter.rb,
app/types/decidim/core/has_publishable_input_filter.rb,
app/types/decidim/core/participatory_space_link_type.rb,
app/functions/decidim/core/needs_api_filter_and_order.rb,
app/functions/decidim/core/participatory_space_finder.rb,
app/types/decidim/core/participatory_space_input_sort.rb,
app/types/decidim/core/participatory_space_input_filter.rb,
app/functions/decidim/core/participatory_space_list_base.rb,
app/functions/decidim/core/participatory_space_finder_base.rb,
lib/decidim/api/participatory_space_resourceable_interface.rb
Overview
This holds the decidim-core version.
Defined Under Namespace
Modules: HasEndorsableInputSort, HasHastaggableInputFilter, HasLocalizedInputFilter, HasLocalizedInputSort, HasPublishableInputFilter, HasPublishableInputSort, HasTimestampInputFilter, HasTimestampInputSort, NeedsApiFilterAndOrder Classes: BaseInputFilter, BaseInputSort, ComponentFinderBase, ComponentInputFilter, ComponentInputSort, ComponentList, ComponentListBase, ComponentListHelper, Engine, MetricResolver, ParticipatorySpaceFinder, ParticipatorySpaceFinderBase, ParticipatorySpaceInputFilter, ParticipatorySpaceInputSort, ParticipatorySpaceList, ParticipatorySpaceListBase, UserEntityFinder, UserEntityInputFilter, UserEntityInputSort, UserEntityList
Constant Summary collapse
- DateType =
GraphQL::ScalarType.define do name "Date" description "An ISO8601 date" coerce_input ->(value, _ctx) { Date.iso8601(value) } coerce_result ->(value, _ctx) { value.to_date.iso8601 } end
- UserType =
This type represents a User.
GraphQL::ObjectType.define do name "User" description "A user" interfaces [ -> { Decidim::Core::AuthorInterface } ] field :id, !types.ID, "The user's id" field :name, !types.String, "The user's name" field :nickname, !types.String, "The user's nickname" do resolve ->(user, _args, _ctx) { user.presenter.nickname } end field :avatarUrl, !types.String, "The user's avatar url" do resolve ->(user, _args, _ctx) { user.presenter.avatar_url(:thumb) } end field :profilePath, !types.String, "The user's profile url" do resolve ->(user, _args, _ctx) { user.presenter.profile_path } end field :directMessagesEnabled, !types.String, "If the user making the request is logged in, it will return whether this recipient accepts a conversation or not. It will return false for non-logged requests." do resolve ->(user, _args, ctx) { user.presenter.(ctx.to_h) } end field :organizationName, !types.String, "The user's organization name" do resolve ->(user, _args, _ctx) { user.organization.name } end field :deleted, !types.Boolean, "Whether the user's account has been deleted or not" do resolve ->(user, _args, _ctx) { user.presenter.deleted? } end field :badge, !types.String, "A badge for the user group" do resolve ->(user, _args, _ctx) { user.presenter.badge } end field :groups, !types[UserGroupType], "Groups where this user belongs" do resolve ->(user, _args, _ctx) { user.accepted_user_groups } end end
- AuthorInterface =
This interface represents an author who owns a resource.
GraphQL::InterfaceType.define do name "Author" description "An author" field :id, !types.ID, "The author ID" field :name, !types.String, "The author's name" field :nickname, !types.String, "The author's nickname" field :avatarUrl, !types.String, "The author's avatar url" field :profilePath, !types.String, "The author's profile path" field :badge, !types.String, "The author's badge icon" field :organizationName, !types.String, "The authors's organization name" do resolve ->(obj, _args, _ctx) { obj.organization.name } end field :deleted, !types.Boolean, "Whether the author's account has been deleted or not" resolve_type ->(obj, _ctx) { return Decidim::Core::UserType if obj.is_a? Decidim::User return Decidim::Core::UserGroupType if obj.is_a? Decidim::UserGroup } end
- MetricType =
GraphQL::ObjectType.define do name "MetricType" description "Metric data" field :name, !types.String, "The name of the metric" field :count, !types.Int, "The last value of the metric" field :history, !types[MetricHistoryType], "The historic values for this metric" end
- ScopableInterface =
This interface represents a scopable object.
GraphQL::InterfaceType.define do name "ScopableInterface" description "An interface that can be used in scopable objects." field :scope, Decidim::Core::ScopeApiType, "The object's scope" end
- DecidimType =
This type represents a Decidim’s global property.
GraphQL::ObjectType.define do name "Decidim" description "Decidim's framework-related properties." field :version, !types.String, "The current decidim's version of this deployment." do resolve ->(obj, _args, _ctx) { obj.version } end field :applicationName, !types.String, "The current installation's name." do resolve ->(obj, _args, _ctx) { obj.application_name } end end
- HashtagType =
This type represents a User.
GraphQL::ObjectType.define do name "HashtagType" description "hashtags list" field :name, !types.String, "The hashtag's name" end
- SessionType =
This type represents the current user session.
GraphQL::ObjectType.define do name "Session" description "The current session" field :user, UserType, "The current user" do resolve ->(obj, _args, _ctx) { obj } end field :verifiedUserGroups, !types[!UserGroupType], "The current user verified user groups" do resolve ->(obj, _args, _ctx) { Decidim::UserGroups::ManageableUserGroups.for(obj).verified } end end
- AmendableInterface =
This interface represents an amendable object.
GraphQL::InterfaceType.define do name "AmendableInterface" description "An interface that can be used in objects with amendments" field :amendments, !types[Decidim::Core::AmendmentType] do description "This object's amendments" resolve lambda { |obj, _args, ctx| obj.visible_amendments_for(ctx[:current_user]) } end end
- ComponentInterface =
GraphQL::InterfaceType.define do name "ComponentInterface" description "This interface is implemented by all components that belong into a Participatory Space" field :id, !types.ID, "The Component's unique ID" field :name, !TranslatedFieldType, "The name of this component." field :weight, !types.Int, "The weight of the component" field :participatorySpace, !ParticipatorySpaceType, "The participatory space in which this component belongs to.", property: :participatory_space resolve_type ->(obj, _ctx) { obj.manifest.query_type.constantize } end
- TraceableInterface =
This interface represents an traceable object.
GraphQL::InterfaceType.define do name "TraceableInterface" description "An interface that can be used in objects with traceability (versions)" field :versionsCount, !types.Int, "Total number of versions", property: :versions_count field :versions, !types[Decidim::Core::TraceVersionType], "This object's versions" end
- AreaApiType =
GraphQL::ObjectType.define do name "Area" description "An area." field :id, !types.ID, "Internal ID for this area" field :name, !TranslatedFieldType, "The name of this area." field :areaType, Decidim::Core::AreaTypeType, "The area type of this area", property: :area_type field :createdAt, !Decidim::Core::DateTimeType, "The time this assembly was created", property: :created_at field :updatedAt, !Decidim::Core::DateTimeType, "The time this assembly was updated", property: :updated_at end
- CategoryType =
GraphQL::ObjectType.define do name "Category" description "A category that can be applied to other resources." field :id, !types.ID field :name, !TranslatedFieldType, "The name of this category." field :subcategories, !types[Decidim::Core::CategoryType], "Subcategories of this category." field :parent, Decidim::Core::CategoryType, "This category's parent category." end
- AttachableInterface =
This interface represents a attachable object.
GraphQL::InterfaceType.define do name "AttachableInterface" description "An interface that can be used in objects with attachments" field :attachments, !types[Decidim::Core::AttachmentType], "This object's attachments" end
- AuthorableInterface =
This interface represents a commentable object.
GraphQL::InterfaceType.define do name "AuthorableInterface" description "An interface that can be used in authorable objects." field :author, Decidim::Core::AuthorInterface, "The resource author" do # can be an Authorable or a Coauthorable resolve ->(, _, _) { if .respond_to?(:normalized_author) &. elsif .respond_to?(:creator_identity) &.creator_identity end } end end
- EndorsableInterface =
This interface represents an object capable of endorsements.
GraphQL::InterfaceType.define do name "EndorsableInterface" description "An interface that can be used in objects with endorsements" field :endorsements, !types[Decidim::Core::AuthorInterface], "The endorsements of this object." do resolve ->(object, _, _) { object.endorsements.map(&:normalized_author) } end field :endorsementsCount, types.Int do description "The total amount of endorsements the object has received" property :endorsements_count end end
- TimestampsInterface =
This interface represents an object with standard create_at and updated_at timestamps.
GraphQL::InterfaceType.define do name "TimestampsInterface" description "An interface that can be used in objects with created_at and updated_at attributes" field :createdAt, Decidim::Core::DateTimeType do description "The date and time this object was created" property :created_at end field :updatedAt, Decidim::Core::DateTimeType do description "The date and time this object was updated" property :updated_at end end
- AmendmentType =
GraphQL::ObjectType.define do name "Amendment" description "An amendment" field :id, !types.ID, "The id of this amendment" field :state, !types.String, "The status of this amendment" field :amender, !Decidim::Core::AuthorInterface, "The author of this amendment" field :amendableType, !types.String do description "Type of the amendable object" property :decidim_amendable_type end field :emendationType, !types.String do description "Type of the emendation object" property :decidim_emendation_type end field :amendable, !AmendableEntityInterface, "The original amended resource (currently, a proposal only)" field :emendation, !AmendableEntityInterface, "The emendation (currently, a proposal only)" end
- AreaTypeType =
GraphQL::ObjectType.define do name "AreaType" description "An area type." field :id, !types.ID, "Internal ID for this area type" field :name, !TranslatedFieldType, "The name of this area type." field :plural, !TranslatedFieldType, "The plural name of this area type" end
- ComponentType =
GraphQL::ObjectType.define do interfaces [-> { ComponentInterface }] name "Component" description "A base component with no particular specificities." end
- DateTimeType =
GraphQL::ScalarType.define do name "DateTime" description "An ISO8601 date with time" coerce_input ->(value, _ctx) { Time.iso8601(value) } coerce_result ->(value, _ctx) { value.to_time.iso8601 } end
- ScopeApiType =
GraphQL::ObjectType.define do name "Scope" description "A scope" field :id, !types.ID field :name, !TranslatedFieldType, "The name of this scope." field :children, !types[Decidim::Core::ScopeApiType], "Descendants of this scope" field :parent, Decidim::Core::ScopeApiType, "This scope's parent scope." end
- StatisticType =
GraphQL::ObjectType.define do name "Statistic" description "Represents a single statistic" field :name, !types.String, "The name of the statistic" do resolve ->(statistic, _args, _ctx) { statistic[0] } end field :value, !types.Int, "The actual value of the statistic" do resolve ->(statistic, _args, _ctx) { statistic[1] } end end
- FingerprintInterface =
This interface represents a fingerprintable object.
GraphQL::InterfaceType.define do name "FingerprintInterface" description "An interface that can be used in fingerprintable objects." field :fingerprint, !Decidim::Core::FingerprintType, "This object's fingerprint" end
- AttachmentType =
GraphQL::ObjectType.define do name "Attachment" description "A file attachment" field :url, !types.String, "The url of this attachment" field :type, !types.String, "The type of this attachment", property: :file_type field :thumbnail, types.String, "A thumbnail of this attachment, if it's an image.", property: :thumbnail_url end
- UserGroupType =
This type represents a UserGroup
GraphQL::ObjectType.define do name "UserGroup" description "A user group" interfaces [ -> { Decidim::Core::AuthorInterface } ] field :id, !types.ID, "The user group's id" field :name, !types.String, "The user group's name" field :nickname, !types.String, "The user group nickname" do resolve ->(group, _args, _ctx) { group.presenter.nickname } end field :avatarUrl, !types.String, "The user's avatar url" do resolve ->(group, _args, _ctx) { group.presenter.avatar_url } end field :profilePath, !types.String, "The user group's profile url" do resolve ->(group, _args, _ctx) { group.presenter.profile_path } end field :organizationName, !types.String, "The user group's organization name" do resolve ->(group, _args, _ctx) { group.organization.name } end field :deleted, !types.Boolean, "Whether the user group's has been deleted or not" do resolve ->(group, _args, _ctx) { group.presenter.deleted? } end field :badge, !types.String, "A badge for the user group" do resolve ->(group, _args, _ctx) { group.presenter.badge } end field :members, !types[UserType], "Members of this group" do resolve ->(group, _args, _ctx) { group.accepted_users } end field :membersCount, !types.Int, "Number of members in this group" do resolve ->(group, _args, _ctx) { group.accepted_memberships.count } end end
GraphQL::InterfaceType.define do name "CoauthorableInterface" description "An interface that can be used in coauthorable objects." field :authorsCount, types.Int do description "The total amount of co-authors that contributed to the proposal. Note that this field may include also non-user authors like meetings or the organization" property :coauthorships_count end field :author, Decidim::Core::AuthorInterface do description "The resource author. Note that this can be null on official proposals or meeting-proposals" resolve ->(resource, _, _) { = resource.creator_identity if .is_a?(Decidim::User) || .is_a?(Decidim::UserGroup) } end field :authors, !types[Decidim::Core::AuthorInterface] do description "The resource co-authors. Include only users or groups of users" property :user_identities end end
- CoordinatesType =
This type represents a Decidim’s global property.
GraphQL::ObjectType.define do name "Coordinates" description "Physical coordinates for a location" field :latitude, !types.Float, "Latitude of this coordinate" do resolve ->(coordinates, _args, _ctx) { coordinates[0] } end field :longitude, !types.Float, "Longitude of this coordinate" do resolve ->(coordinates, _args, _ctx) { coordinates[1] } end end
- FingerprintType =
GraphQL::ObjectType.define do name "Fingerprint" description "A fingerprint object" field :value, !types.String, "The the hash value for the fingerprint" field :source, !types.String do description "Returns the source String (usually a json) from which the fingerprint is generated." end end
- CategorizableInterface =
This interface represents a categorizable object.
GraphQL::InterfaceType.define do name "CategorizableInterface" description "An interface that can be used in categorizable objects." field :category, !Decidim::Core::CategoryType, "The object's category" end
- OrganizationType =
GraphQL::ObjectType.define do name "Organization" description "The current organization" field :name, types.String, "The name of the current organization" field :stats do type types[Core::StatisticType] description "The statistics associated to this object" resolve ->(object, _args, _ctx) { Decidim.stats.with_context(object) } end end
- TraceVersionType =
GraphQL::ObjectType.define do name "TraceVersion" description "A trace version type" field :id, !types.ID, "The ID of the version" field :createdAt, Decidim::Core::DateTimeType do description "The date and time this version was created" property :created_at end field :editor, Decidim::Core::AuthorInterface do description "The editor/author of this version" resolve ->(obj, _args, _ctx) { = Decidim.traceability.version_editor(obj) if .is_a?(Decidim::User) || .is_a?(Decidim::UserGroup) } end field :changeset, GraphQL::Types::JSON do description "Object with the changes in this version" resolve ->(obj, _args, _ctx) { obj.changeset } end end
- MetricHistoryType =
GraphQL::ObjectType.define do name "MetricHistory" field :key, !types.String, "The key value" do resolve ->(obj, _args, _ctx) { MetricObjectPresenter.new(obj).attr_date(0) } end field :value, !types.Int, "The value for each key" do resolve ->(obj, _args, _ctx) { MetricObjectPresenter.new(obj).attr_int(1) } end end
- AmendableEntityInterface =
This interface should be implemented by any Type that can be used as amendment The only requirement is to have an ID and the Type name be the class.name + Type
GraphQL::InterfaceType.define do name "AmendableEntityInterface" description "An interface that can be used in objects with amendments" field :id, !types.ID, "ID of this entity" resolve_type ->(obj, _ctx) { "#{obj.class.name}Type".constantize } end
- LocalizedStringType =
This type represents a localized string in a single language.
GraphQL::ObjectType.define do name "LocalizedString" description "Represents a particular translation of a LocalizedStringType" field :locale, !types.String, "The standard locale of this translation." field :text, types.String, "The content of this translation." end
- TranslatedFieldType =
This type represents a translated field in multiple languages.
GraphQL::ObjectType.define do name "TranslatedField" description "A translated field" field :locales do type types[types.String] description "Lists all the locales in which this translation is available" resolve ->(obj, _args, _ctx) { obj.keys } end field :translations do type !types[LocalizedStringType] description "All the localized strings for this translation." argument :locales do type types[!types.String] description "A list of locales to scope the translations to." end resolve lambda { |obj, args, _ctx| translations = obj.stringify_keys translations = translations.slice(*args["locales"]) if args["locales"] translations.map { |locale, text| OpenStruct.new(locale: locale, text: text) } } end field :translation do type types.String description "Returns a single translation given a locale." argument :locale, !types.String, "A locale to search for" resolve lambda { |obj, args, _ctx| translations = obj.stringify_keys translations[args["locale"]] } end end
- ParticipatorySpaceInterface =
GraphQL::InterfaceType.define do name "ParticipatorySpaceInterface" description "The interface that all participatory spaces should implement." field :id, !types.ID, "The participatory space's unique ID" field :title, !TranslatedFieldType, "The name of this participatory space." field :type, !types.String do description "The participatory space class name. i.e. Decidim::ParticipatoryProcess" resolve ->(participatory_space, _args, _ctx) { participatory_space.class.name } end field :components, type: types[ComponentInterface], description: "Lists the components this space contains.", function: ComponentListHelper.new field :stats, types[Decidim::Core::StatisticType] do resolve ->(participatory_space, _args, _ctx) { return if participatory_space.respond_to?(:show_statistics) && !participatory_space.show_statistics published_components = Component.where(participatory_space: participatory_space).published stats = Decidim.component_manifests.map do |component_manifest| component_manifest.stats.with_context(published_components).map { |name, data| [name, data] }.flatten end stats.reject(&:empty?) } end resolve_type ->(obj, _ctx) { obj.manifest.query_type.constantize } end
- ParticipatorySpaceType =
GraphQL::ObjectType.define do interfaces [-> { ParticipatorySpaceInterface }] name "ParticipatorySpace" description "A participatory space" end
- ParticipatorySpaceLinkType =
GraphQL::ObjectType.define do name "ParticipatorySpaceLink" description "A link representation between participatory spaces" field :id, !types.ID, "The id of this participatory space link" field :fromType, !types.String, "The origin participatory space type for this participatory space link", property: :from_type field :toType, !types.String, "The destination participatory space type for this participatory space link", property: :to_type field :name, !types.String, "The name (purpose) of this participatory space link" field :participatorySpace, !ParticipatorySpaceInterface do description "The linked participatory space (polymorphic)" resolve ->(link, _args, _ctx) { manifest_name = link.name.partition("included_").last object_class = "Decidim::#{manifest_name.classify}" return link.to if link.to_type == object_class return link.from if link.from_type == object_class } end end
- ParticipatorySpaceResourceableInterface =
This interface represents a participatorySpaceResourceable object. It create and array of linked participatory spaces for each registered manifest
GraphQL::InterfaceType.define do name "ParticipatorySpaceResourcableInterface" description "An interface that can be used in objects with participatorySpaceResourceable" # this handles the cases linked_participatory_space_resources(:participatory_space, :included_participatory_space) field "linkedParticipatorySpaces", !types[ParticipatorySpaceLinkType] do description "Lists all linked participatory spaces in a polymorphic way" resolve ->(participatory_space, _args, _ctx) { Decidim::ParticipatorySpaceLink.where("name like 'included_%' and ((from_id=:id and from_type=:type) or (to_id=:id and to_type=:type))", id: participatory_space.id, type: participatory_space.class.name) } end end
Class Method Summary collapse
Class Method Details
.version ⇒ Object
6 7 8 |
# File 'lib/decidim/core/version.rb', line 6 def self.version "0.23.1" end |