# TODO: replace this file with one that defines the schema for your own dataset.
ElasticGraph.define_schema do |schema|
  schema.enum_type "MusicGenre" do |t|
    t.value "ALTERNATIVE"
    t.value "BLUES"
    t.value "BLUEGRASS"
    t.value "CLASSICAL"
    t.value "COUNTRY"
    t.value "ELECTRONIC"
    t.value "FOLK"
    t.value "HIP_HOP"
    t.value "INDIE"
    t.value "JAZZ"
    t.value "METAL"
    t.value "POP"
    t.value "PUNK"
    t.value "REGGAE"
    t.value "RNB"
    t.value "ROCK"
    t.value "SKA"
    t.value "SOUL"
  end

  schema.object_type "Artist" do |t|
    t.field "id", "ID"
    t.field "name", "String"
    t.field "lifetimeSales", "JsonSafeLong"
    t.field "bio", "ArtistBio"
    t.field "genres", "[MusicGenre!]!"

    t.field "albums", "[Album!]!" do |f|
      f.mapping type: "nested"
    end

    t.field "tours", "[Tour!]!" do |f|
      f.mapping type: "nested"
    end

    t.index "artists"
  end

  schema.object_type "ArtistBio" do |t|
    t.field "yearFormed", "Int"
    t.field "homeCountry", "String"
    t.field "description", "String" do |f|
      f.mapping type: "text"
    end
  end

  schema.object_type "Album" do |t|
    t.field "name", "String"
    t.field "releasedOn", "Date"
    t.field "soldUnits", "Int"
    t.field "tracks", "[AlbumTrack!]!" do |f|
      f.mapping type: "nested"
    end
  end

  schema.object_type "AlbumTrack" do |t|
    t.field "name", "String"
    t.field "trackNumber", "Int"
    t.field "lengthInSeconds", "Int"
  end

  schema.object_type "Tour" do |t|
    t.field "name", "String"
    t.field "shows", "[Show!]!" do |f|
      f.mapping type: "nested"
    end
  end

  schema.object_type "Show" do |t|
    t.relates_to_one "venue", "Venue", via: "venueId", dir: :out
    t.field "attendance", "Int"
    t.field "startedAt", "DateTime"
  end

  schema.object_type "Venue" do |t|
    t.field "id", "ID"
    t.field "name", "String"
    t.field "location", "GeoLocation"
    t.field "capacity", "Int"
    t.relates_to_many "featuredArtists", "Artist", via: "tours.shows.venueId", dir: :in, singular: "featuredArtist"

    t.index "venues"
  end
end
