diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index 3b4b60f9f..aaeef9048 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -35,7 +35,7 @@ module DoiItem field :provider, ProviderType, null: true, description: "The provider account managing this resource" def type - object.types["schema_org"] + object.types["schemaOrg"] end def creators(first: nil) diff --git a/app/models/doi.rb b/app/models/doi.rb index d910a9865..f361dd82f 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -72,7 +72,7 @@ class Doi < ActiveRecord::Base has_many :media, -> { order "created DESC" }, foreign_key: :dataset, dependent: :destroy has_many :metadata, -> { order "created DESC" }, foreign_key: :dataset, dependent: :destroy - delegate :provider, to: :client + delegate :provider, to: :client, allow_nil: true delegate :consortium_id, to: :provider, allow_nil: true validates_presence_of :doi @@ -452,8 +452,8 @@ def as_indexed_json(options={}) "created" => created, "updated" => updated, "published" => published, - "client" => client.as_indexed_json, - "provider" => provider.as_indexed_json, + "client" => client.try(:as_indexed_json), + "provider" => provider.try(:as_indexed_json), "resource_type" => resource_type.try(:as_indexed_json), "media" => media.map { |m| m.try(:as_indexed_json) } } @@ -628,6 +628,8 @@ def uid def resource_type_id types["resourceTypeGeneral"].underscore.dasherize if types.to_h["resourceTypeGeneral"].present? + rescue TypeError + nil end def media_ids