Skip to content

Commit

Permalink
namespace graphql types
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 26, 2020
1 parent 58529dd commit ecfaa2a
Show file tree
Hide file tree
Showing 198 changed files with 1,085 additions and 522 deletions.
2 changes: 1 addition & 1 deletion app/graphql/lupo_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LupoSchema < GraphQL::Schema
max_depth 10

# mutation(Types::MutationType)
query(QueryType)
query(Types::QueryType)

use GraphQL::Batch
use GraphQL::Cache
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/address_type.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class AddressType < BaseObject
class Types::AddressType < Types::BaseObject
description "Information about addresses"

field :type, String, null: true, description: "The type."
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/affiliation_type.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class AffiliationType < BaseObject
class Types::AffiliationType < Types::BaseObject
description "Information about affiliations"

field :id, ID, null: true, description: "Affiliation ROR identifier"
Expand Down
12 changes: 6 additions & 6 deletions app/graphql/types/audiovisual_connection_type.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

class AudiovisualConnectionType < BaseConnection
edge_type(AudiovisualEdgeType)
class Types::AudiovisualConnectionType < Types::BaseConnection
edge_type(Types::AudiovisualEdgeType)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :years, [FacetType], null: true, cache: true
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :years, [Types::FacetType], null: true, cache: true
field :registration_agencies, [Types::FacetType], null: true, cache: true
field :repositories, [Types::FacetType], null: true, cache: true
field :affiliations, [Types::FacetType], null: true, cache: true

def total_count
args = prepare_args(object.arguments)
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/audiovisual_edge_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class AudiovisualEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(AudiovisualType)
class Types::AudiovisualEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(Types::AudiovisualType)
end
4 changes: 2 additions & 2 deletions app/graphql/types/audiovisual_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class AudiovisualType < BaseObject
implements DoiItem
class Types::AudiovisualType < Types::BaseObject
implements Types::DoiItem
end
2 changes: 1 addition & 1 deletion app/graphql/types/base_connection.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class BaseConnection < GraphQL::Types::Relay::BaseConnection
class Types::BaseConnection < GraphQL::Types::Relay::BaseConnection
def doi_from_url(url)
if /\A(?:(http|https):\/\/(dx\.)?(doi.org|handle.test.datacite.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match?(url)
uri = Addressable::URI.parse(url)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/base_enum.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

class BaseEnum < GraphQL::Schema::Enum
class Types::BaseEnum < GraphQL::Schema::Enum
end
2 changes: 1 addition & 1 deletion app/graphql/types/base_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'apollo-federation'

class BaseField < GraphQL::Schema::Field
class Types::BaseField < GraphQL::Schema::Field
include ApolloFederation::Field

#field_class GraphQL::Cache::Field
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/base_input_object.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

class BaseInputObject < GraphQL::Schema::InputObject
class Types::BaseInputObject < GraphQL::Schema::InputObject
end
4 changes: 2 additions & 2 deletions app/graphql/types/base_interface.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

module BaseInterface
module Types::BaseInterface
include GraphQL::Schema::Interface
include ApolloFederation::Interface

field_class BaseField
field_class Types::BaseField
end
4 changes: 2 additions & 2 deletions app/graphql/types/base_object.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

class BaseObject < GraphQL::Schema::Object
class Types::BaseObject < GraphQL::Schema::Object
include ApolloFederation::Object

field_class BaseField
field_class Types::BaseField

def doi_from_url(url)
if /\A(?:(http|https):\/\/(dx\.)?(doi.org|handle.test.datacite.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match?(url)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/base_scalar.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

class BaseScalar < GraphQL::Schema::Scalar
class Types::BaseScalar < GraphQL::Schema::Scalar
end
2 changes: 1 addition & 1 deletion app/graphql/types/base_union.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

class BaseUnion < GraphQL::Schema::Union
class Types::BaseUnion < GraphQL::Schema::Union
end
10 changes: 5 additions & 5 deletions app/graphql/types/book_chapter_connection_type.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

class BookChapterConnectionType < BaseConnection
class Types::BookChapterConnectionType < Types::BaseConnection
edge_type(BookChapterEdgeType)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :years, [FacetType], null: true, cache: true
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :years, [Types::FacetType], null: true, cache: true
field :registration_agencies, [Types::FacetType], null: true, cache: true
field :repositories, [Types::FacetType], null: true, cache: true
field :affiliations, [Types::FacetType], null: true, cache: true

def total_count
args = prepare_args(object.arguments)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/book_chapter_edge_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class BookChapterEdgeType < GraphQL::Types::Relay::BaseEdge
class Types::BookChapterEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(BookChapterType)
end
4 changes: 2 additions & 2 deletions app/graphql/types/book_chapter_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class BookChapterType < BaseObject
implements DoiItem
class Types::BookChapterType < Types::BaseObject
implements Types::DoiItem

def type
"BookChapter"
Expand Down
10 changes: 5 additions & 5 deletions app/graphql/types/book_connection_type.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

class BookConnectionType < BaseConnection
class Types::BookConnectionType < Types::BaseConnection
edge_type(BookEdgeType)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :years, [FacetType], null: true, cache: true
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :years, [Types::FacetType], null: true, cache: true
field :registration_agencies, [Types::FacetType], null: true, cache: true
field :repositories, [Types::FacetType], null: true, cache: true
field :affiliations, [Types::FacetType], null: true, cache: true

def total_count
args = prepare_args(object.arguments)
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/book_edge_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class BookEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(BookType)
class Types::BookEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(Types::BookType)
end
4 changes: 2 additions & 2 deletions app/graphql/types/book_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class BookType < BaseObject
implements DoiItem
class Types::BookType < Types::BaseObject
implements Types::DoiItem

def type
"Book"
Expand Down
10 changes: 5 additions & 5 deletions app/graphql/types/collection_connection_type.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

class CollectionConnectionType < BaseConnection
edge_type(CollectionEdgeType)
class Types::CollectionConnectionType < Types::BaseConnection
edge_type(Types::CollectionEdgeType)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :years, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :years, [Types::FacetType], null: true, cache: true
field :repositories, [Types::FacetType], null: true, cache: true
field :affiliations, [Types::FacetType], null: true, cache: true

def total_count
args = prepare_args(object.arguments)
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/collection_edge_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class CollectionEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(CollectionType)
class Types::CollectionEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(Types::CollectionType)
end
4 changes: 2 additions & 2 deletions app/graphql/types/collection_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class CollectionType < BaseObject
implements DoiItem
class Types::CollectionType < Types::BaseObject
implements Types::DoiItem
end
12 changes: 6 additions & 6 deletions app/graphql/types/conference_paper_connection_type.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

class ConferencePaperConnectionType < BaseConnection
edge_type(ConferencePaperEdgeType)
class Types::ConferencePaperConnectionType < Types::BaseConnection
edge_type(Types::ConferencePaperEdgeType)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :years, [FacetType], null: true, cache: true
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :years, [Types::FacetType], null: true, cache: true
field :registration_agencies, [Types::FacetType], null: true, cache: true
field :repositories, [Types::FacetType], null: true, cache: true
field :affiliations, [Types::FacetType], null: true, cache: true

def total_count
args = prepare_args(object.arguments)
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/conference_paper_edge_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class ConferencePaperEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(ConferencePaperType)
class Types::ConferencePaperEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(Types::ConferencePaperType)
end
4 changes: 2 additions & 2 deletions app/graphql/types/conference_paper_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ConferencePaperType < BaseObject
implements DoiItem
class Types::ConferencePaperType < Types::BaseObject
implements Types::DoiItem

def type
"ConferencePaper"
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/country_type.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class CountryType < BaseObject
class Types::CountryType < Types::BaseObject
description "Information about countries"

field :code, String, null: true, description: "Country ISO 3166-1 code"
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/creator_type.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

class CreatorType < BaseObject
class Types::CreatorType < Types::BaseObject
description "A creator."

field :id, ID, null: true, description: "The ID of the creator."
field :type, String, null: false, description: "The type of the item."
field :name, String, null: false, description: "The name of the creator."
field :given_name, String, null: true, description: "Given name. In the U.S., the first name of a Person."
field :family_name, String, null: true, description: "Family name. In the U.S., the last name of an Person."
field :affiliation, [OrganizationType], null: true, description: "The organizational or institutional affiliation of the creator."
field :affiliation, [Types::OrganizationType], null: true, description: "The organizational or institutional affiliation of the creator."

def type
object.name_type == "Organizational" ? "Organization" : "Person"
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/data_catalog_connection_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class DataCatalogConnectionType < BaseConnection
edge_type(DataCatalogEdgeType)
class Types::DataCatalogConnectionType < Types::BaseConnection
edge_type(Types::DataCatalogEdgeType)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: true, cache: true
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/data_catalog_edge_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class DataCatalogEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(DataCatalogType)
class Types::DataCatalogEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(Types::DataCatalogType)
end
16 changes: 8 additions & 8 deletions app/graphql/types/data_catalog_type.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# frozen_string_literal: true

class DataCatalogType < BaseObject
class Types::DataCatalogType < Types::BaseObject
description "A collection of datasets."

field :id, ID, null: false, description: "The ID of the data catalog."
field :type, String, null: false, description: "The type of the item."
field :identifier, [IdentifierType], null: true, description: "re3data ID"
field :identifier, [Types::IdentifierType], null: true, description: "re3data ID"
field :name, String, null: true, description: "The name of the data catalog."
field :alternate_name, [String], null: true, description: "An alias for the data catalog."
field :url, String, null: true, hash_key: "repositoryUrl", description: "URL of the data catalog."
field :contacts, [String], null: true, description: "Repository contact information"
field :description, String, null: true, description: "A description of the data catalog."
field :certificates, [DefinedTermType], null: true, description: "Certificates of the data catalog."
field :subjects, [DefinedTermType], null: true, description: "Subject areas covered by the data catalog."
field :certificates, [Types::DefinedTermType], null: true, description: "Certificates of the data catalog."
field :subjects, [Types::DefinedTermType], null: true, description: "Subject areas covered by the data catalog."
# field :types, [String], null: true, description: "Repository types"
# field :content_types, [SchemeType], null: true, description: "Content types"
field :provider_types, [String], null: true, description: "Provider types"
field :in_language, [String], null: true, description: "The language of the content of the data catalog."
field :keywords, String, null: true, description: "Keywords or tags used to describe this data catalog. Multiple entries in a keywords list are typically delimited by commas."
field :data_accesses, [TextRestrictionType], null: true, description: "Data accesses"
field :data_uploads, [TextRestrictionType], null: true, description: "Data uploads"
field :data_accesses, [Types::TextRestrictionType], null: true, description: "Data accesses"
field :data_uploads, [Types::TextRestrictionType], null: true, description: "Data uploads"
field :pid_systems, [String], null: true, description: "PID Systems"
# field :apis, [ApiType], null: true, description: "APIs"
field :software_application, [SoftwareApplicationType], null: true, description: "Software"
field :software_application, [Types::SoftwareApplicationType], null: true, description: "Software"
field :view_count, Integer, null: true, description: "The number of views according to the Counter Code of Practice."
field :download_count, Integer, null: true, description: "The number of downloads according to the Counter Code of Practice."
field :citation_count, Integer, null: true, description: "The number of citations."

field :datasets, DatasetConnectionType, null: true, description: "Funded datasets", connection: true do
field :datasets, Types::DatasetConnectionType, null: true, description: "Funded datasets", connection: true do
argument :query, String, required: false
argument :user_id, String, required: false
argument :repository_id, String, required: false
Expand Down
12 changes: 6 additions & 6 deletions app/graphql/types/data_paper_connection_type.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

class DataPaperConnectionType < BaseConnection
edge_type(DataPaperEdgeType)
class Types::DataPaperConnectionType < Types::BaseConnection
edge_type(Types::DataPaperEdgeType)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :years, [FacetType], null: true, cache: true
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :years, [Types::FacetType], null: true, cache: true
field :registration_agencies, [Types::FacetType], null: true, cache: true
field :repositories, [Types::FacetType], null: true, cache: true
field :affiliations, [Types::FacetType], null: true, cache: true

def total_count
args = prepare_args(object.arguments)
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/data_paper_edge_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class DataPaperEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(DataPaperType)
class Types::DataPaperEdgeType < GraphQL::Types::Relay::BaseEdge
node_type(Types::DataPaperType)
end
4 changes: 2 additions & 2 deletions app/graphql/types/data_paper_type.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class DataPaperType < BaseObject
implements DoiItem
class Types::DataPaperType < Types::BaseObject
implements Types::DoiItem
end
Loading

0 comments on commit ecfaa2a

Please sign in to comment.