Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new data_resource GenericItem #190

Merged
merged 24 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c2dc0f6
Add new data_resource GenericItem
marcometz Feb 16, 2021
ad941a5
Reorganize QueryTypes
marcometz Feb 17, 2021
e7d70e8
Reorganize InputTypes
marcometz Feb 17, 2021
083da92
Verschachtelte GenericItems
marcometz Feb 17, 2021
9dba997
Fix for CompanyAssignment
marcometz Feb 18, 2021
af0d6e0
Adding Payload JSON to graphql schema
marcometz Feb 18, 2021
7c4c6c7
Scope for user an role
marcometz Feb 19, 2021
daf55e3
Create category by name ob by list of names
marcometz Feb 19, 2021
d4c4f6a
GraphQL Schema aktualisiert
marcometz Feb 19, 2021
b347f79
Sortierung nach PublishedAt integriert
marcometz Feb 23, 2021
bc7856e
Weitere Filter für genericItem hinzugefügt
marcometz Feb 23, 2021
baf30a6
Weitere nested Models zu GenericItem hinzugefügt
marcometz Feb 23, 2021
8290bdc
Relation dates zu genericItem hinzugefügt
marcometz Feb 23, 2021
df9fe2c
accessibility_informations hinzugefügt zu Graphql
marcometz Feb 23, 2021
7e055eb
Codestyle verbessert
marcometz Feb 23, 2021
a9dba25
GenericItem graphQl erweitert um contacts
marcometz Feb 23, 2021
ba1eec2
Überflüssige Klassenzuweisung entfernt
marcometz Feb 23, 2021
3f6b8ac
Schema erneuert und ID als Pflichtfeld bei GenericItem show
marcometz Feb 23, 2021
b78fb67
Fixing GenericItem show graphql endpoint
marcometz Feb 23, 2021
debe024
Neuer API Endpunkt CategoryTree
marcometz Feb 23, 2021
4cc5400
Unused ForceCreate hinzugefügt
marcometz Feb 24, 2021
fb8e370
Löschen von GenericItems erlauben
marcometz Feb 24, 2021
a1b1791
Sortierung nach publication_date hinzugefügt
marcometz Mar 10, 2021
72fbd5b
Sortieroptionen einheitlich 'sortiert'
marcometz Mar 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/graphql/mutations/create_app_user_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CreateAppUserContent < BaseMutation
argument :data_type, String, required: false
argument :content, String, required: false

type Types::AppUserContentType
type Types::QueryTypes::AppUserContentType

def resolve(**params)
return spam_message if spam?
Expand Down
28 changes: 14 additions & 14 deletions app/graphql/mutations/create_event_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,62 @@ class CreateEventRecord < BaseMutation
argument :description, String, required: false
argument :external_id, String, required: false
argument :title, String, required: false
argument :dates, [Types::DateInput], required: false,
argument :dates, [Types::InputTypes::DateInput], required: false,
as: :dates_attributes,
prepare: ->(dates, _ctx) { dates.map(&:to_h) }
argument :repeat, Boolean, required: false
argument :repeat_duration, Types::RepeatDurationInput, required: false,
argument :repeat_duration, Types::InputTypes::RepeatDurationInput, required: false,
as: :repeat_duration_attributes,
prepare: lambda { |repeat_duration, _ctx|
repeat_duration.to_h
}
argument :category_name, String, required: false
argument :categories, [Types::CategoryInput], required: false,
argument :categories, [Types::InputTypes::CategoryInput], required: false,
as: :category_names,
prepare: lambda { |category, _ctx|
category.map(&:to_h)
}
argument :region_name, String, required: false
argument :region, Types::RegionInput, required: false
argument :addresses, [Types::AddressInput], required: false,
argument :region, Types::InputTypes::RegionInput, required: false
argument :addresses, [Types::InputTypes::AddressInput], required: false,
as: :addresses_attributes,
prepare: lambda { |addresses, _ctx|
addresses.map(&:to_h)
}
argument :location, Types::LocationInput, required: false,
argument :location, Types::InputTypes::LocationInput, required: false,
as: :location_attributes,
prepare: ->(location, _ctx) { location.to_h }
argument :contacts, [Types::ContactInput], required: false, as: :contacts_attributes,
argument :contacts, [Types::InputTypes::ContactInput], required: false, as: :contacts_attributes,
prepare: ->(contacts, _ctx) { contacts.map(&:to_h) }
argument :urls, [Types::WebUrlInput], required: false, as: :urls_attributes,
argument :urls, [Types::InputTypes::WebUrlInput], required: false, as: :urls_attributes,
prepare: ->(urls, _ctx) { urls.map(&:to_h) }
argument :media_contents, [Types::MediaContentInput], required: false,
argument :media_contents, [Types::InputTypes::MediaContentInput], required: false,
as: :media_contents_attributes,
prepare: lambda { |media_contents, _ctx|
media_contents.map(&:to_h)
}
argument :organizer, Types::OperatingCompanyInput, required: false,
argument :organizer, Types::InputTypes::OperatingCompanyInput, required: false,
as: :organizer_attributes,
prepare: lambda { |organizer, _ctx|
organizer.to_h
}
argument :price_informations, [Types::PriceInput], required: false,
argument :price_informations, [Types::InputTypes::PriceInput], required: false,
as: :price_informations_attributes,
prepare: lambda { |price_informations, _ctx|
price_informations.map(&:to_h)
}
argument :accessibility_information,
Types::AccessibilityInformationInput,
Types::InputTypes::AccessibilityInformationInput,
required: false,
as: :accessibility_information_attributes,
prepare: lambda { |accessibility_information, _ctx|
accessibility_information.to_h
}
argument :tags, [String], as: :tag_list, required: false

field :event, Types::EventRecordType, null: true
field :event, Types::QueryTypes::EventRecordType, null: true

type Types::EventRecordType
type Types::QueryTypes::EventRecordType

def resolve(**params)
ResourceService.new(data_provider: context[:current_user].try(:data_provider))
Expand Down
93 changes: 93 additions & 0 deletions app/graphql/mutations/create_generic_item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# frozen_string_literal: true

module Mutations
class CreateGenericItem < BaseMutation
argument :force_create, Boolean, required: false
argument :push_notification, Boolean, required: false
argument :author, String, required: false
argument :title, String, required: false
argument :generic_type, String, required: false
argument :external_id, String, required: false
argument :publication_date, String, required: false
argument :published_at, String, required: false
argument :category_name, String, required: false
argument :payload, GraphQL::Types::JSON, required: false
argument :contacts, [Types::InputTypes::ContactInput],
required: false, as: :contacts_attributes,
prepare: ->(contacts, _ctx) { contacts.map(&:to_h) }
argument :generic_items, [Types::InputTypes::GenericItemInput], required: false,
as: :generic_items_attributes,
prepare: lambda { |generic_items, _ctx|
generic_items.map(&:to_h)
}
argument :companies, [Types::InputTypes::OperatingCompanyInput], required: false,
as: :companies_attributes,
prepare: lambda { |companies, _ctx|
companies.map(&:to_h)
}
argument :categories, [Types::InputTypes::CategoryInput], required: false,
as: :category_names,
prepare: lambda { |category, _ctx|
category.map(&:to_h)
}
argument :web_urls, [Types::InputTypes::WebUrlInput], required: false,
as: :web_urls_attributes,
prepare: ->(source_url, _ctx) { source_url.map(&:to_h) }
argument :addresses, [Types::InputTypes::AddressInput], required: false,
as: :address_attributes,
prepare: lambda { |address, _ctx|
address.to_h
}
argument :content_blocks, [Types::InputTypes::ContentBlockInput], required: false,
as: :content_blocks_attributes,
prepare: lambda { |content_blocks, _ctx|
content_blocks.map(&:to_h)
}
marcometz marked this conversation as resolved.
Show resolved Hide resolved
argument :opening_hours, [Types::InputTypes::OpeningHourInput], required: false,
as: :opening_hours_attributes,
prepare: lambda { |opening_hours, _ctx|
opening_hours.map(&:to_h)
}
argument :price_informations, [Types::InputTypes::PriceInput], required: false,
as: :price_informations_attributes,
prepare: lambda { |price_informations, _ctx|
price_informations.map(&:to_h)
}
argument :media_contents, [Types::InputTypes::MediaContentInput], required: false,
as: :media_contents_attributes,
prepare: lambda { |media_contents, _ctx|
media_contents.map(&:to_h)
}
argument :locations, [Types::InputTypes::LocationInput], required: false,
as: :locations_attributes,
prepare: ->(location, _ctx) { location.map(&:to_h) }
argument :dates, [Types::InputTypes::DateInput], required: false,
as: :dates_attributes,
prepare: ->(dates, _ctx) { dates.map(&:to_h) }
argument :accessibility_informations, [Types::InputTypes::AccessibilityInformationInput],
required: false, as: :accessibility_informations_attributes,
prepare: lambda { |accessibility_informations, _ctx|
accessibility_informations.map(&:to_h)
}

type Types::QueryTypes::GenericItemType

def resolve(**params)
create_generic_item_node(params, nil)
end

def create_generic_item_node(params, parent_id)
nested_params = params.delete(:generic_items_attributes)
parent = ResourceService.new(data_provider: context[:current_user].try(:data_provider))
.create(GenericItem, params.merge(parent_id: parent_id))

return parent if nested_params.blank?

nested_params.each do |nested_param|
create_generic_item_node(nested_param, parent.id)
end

parent
end
end
end
12 changes: 6 additions & 6 deletions app/graphql/mutations/create_news_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ class CreateNewsItem < BaseMutation
argument :published_at, String, required: false
argument :show_publish_date, Boolean, required: false
argument :category_name, String, required: false
argument :categories, [Types::CategoryInput], required: false,
argument :categories, [Types::InputTypes::CategoryInput], required: false,
as: :category_names,
prepare: lambda { |category, _ctx|
category.map(&:to_h)
}
argument :source_url, Types::WebUrlInput, required: false,
argument :source_url, Types::InputTypes::WebUrlInput, required: false,
as: :source_url_attributes,
prepare: ->(source_url, _ctx) { source_url.to_h }
argument :address, Types::AddressInput, required: false,
argument :address, Types::InputTypes::AddressInput, required: false,
as: :address_attributes,
prepare: lambda { |address, _ctx|
address.to_h
}
argument :content_blocks, [Types::ContentBlockInput], required: false,
argument :content_blocks, [Types::InputTypes::ContentBlockInput], required: false,
as: :content_blocks_attributes,
prepare: lambda { |content_blocks, _ctx|
content_blocks.map(&:to_h)
}

field :news_item, Types::NewsItemType, null: true
field :news_item, Types::QueryTypes::NewsItemType, null: true

type Types::NewsItemType
type Types::QueryTypes::NewsItemType

def resolve(**params)
ResourceService.new(data_provider: context[:current_user].try(:data_provider))
Expand Down
28 changes: 14 additions & 14 deletions app/graphql/mutations/create_point_of_interest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,52 @@ class CreatePointOfInterest < BaseMutation
argument :mobile_description, String, required: false
argument :active, Boolean, required: false
argument :category_name, String, required: false
argument :categories, [Types::CategoryInput], required: false,
argument :categories, [Types::InputTypes::CategoryInput], required: false,
as: :category_names,
prepare: lambda { |category, _ctx|
category.map(&:to_h)
}
argument :addresses, [Types::AddressInput], required: false,
argument :addresses, [Types::InputTypes::AddressInput], required: false,
as: :addresses_attributes,
prepare: lambda { |addresses, _ctx|
addresses.map(&:to_h)
}

argument :contact, Types::ContactInput,
argument :contact, Types::InputTypes::ContactInput,
required: false, as: :contact_attributes,
prepare: ->(contact, _ctx) { contact.to_h }

argument :price_informations, [Types::PriceInput],
argument :price_informations, [Types::InputTypes::PriceInput],
required: false, as: :price_informations_attributes,
prepare: ->(price_informations, _ctx) { price_informations.map(&:to_h) }
argument :opening_hours, [Types::OpeningHourInput], required: false,
argument :opening_hours, [Types::InputTypes::OpeningHourInput], required: false,
as: :opening_hours_attributes,
prepare: lambda { |opening_hours, _ctx|
opening_hours.map(&:to_h)
}
argument :operating_company, Types::OperatingCompanyInput, required: false,
argument :operating_company, Types::InputTypes::OperatingCompanyInput, required: false,
as: :operating_company_attributes,
prepare:
lambda { |operating_company, _ctx|
operating_company.to_h
}
argument :web_urls, [Types::WebUrlInput], required: false, as: :web_urls_attributes,
argument :web_urls, [Types::InputTypes::WebUrlInput], required: false, as: :web_urls_attributes,
prepare: ->(web_urls, _ctx) { web_urls.map(&:to_h) }
argument :media_contents, [Types::MediaContentInput], required: false,
argument :media_contents, [Types::InputTypes::MediaContentInput], required: false,
as: :media_contents_attributes,
prepare: lambda { |media_contents, _ctx|
media_contents.map(&:to_h)
}
argument :location, Types::LocationInput, required: false,
argument :location, Types::InputTypes::LocationInput, required: false,
as: :location_attributes,
prepare: ->(location, _ctx) { location.to_h }
argument :certificates, [Types::CertificateInput], required: false,
argument :certificates, [Types::InputTypes::CertificateInput], required: false,
as: :certificates_attributes,
prepare: lambda { |certificates, _ctx|
certificates.map(&:to_h)
}
argument :accessibility_information,
Types::AccessibilityInformationInput,
Types::InputTypes::AccessibilityInformationInput,
required: false,
as: :accessibility_information_attributes,
prepare: lambda { |accessibility_information, _ctx|
Expand All @@ -63,14 +63,14 @@ class CreatePointOfInterest < BaseMutation
argument :tags, [String], as: :tag_list, required: false

argument :lunches,
[Types::LunchInput],
[Types::InputTypes::LunchInput],
required: false,
as: :lunches_attributes,
prepare: ->(lunches, _ctx) { lunches.map(&:to_h) }

field :point_of_interest, Types::PointOfInterestType, null: false
field :point_of_interest, Types::QueryTypes::PointOfInterestType, null: false

type Types::PointOfInterestType
type Types::QueryTypes::PointOfInterestType

def resolve(**params)
ResourceService.new(data_provider: context[:current_user].try(:data_provider))
Expand Down
Loading