Skip to content

Instantly share code, notes, and snippets.

@ericlewis
Created July 31, 2019 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericlewis/6f7856480f9ae94ab733a87592b848f3 to your computer and use it in GitHub Desktop.
Save ericlewis/6f7856480f9ae94ab733a87592b848f3 to your computer and use it in GitHub Desktop.
const { gql } = require("apollo-server");
const typeDefs = gql`
type PageInfo {
hasNextPage: Boolean
}
type ArtistEdge {
node: Artist
}
type ArtistConnection {
edges: [ArtistEdge!]
cursor: ID
pageInfo: PageInfo
}
type AlbumEdge {
node: Album
}
type AlbumConnection {
edges: [AlbumEdge!]
cursor: ID
pageInfo: PageInfo
}
type SongEdge {
node: Song
}
type SongConnection {
edges: [SongEdge!]
cursor: ID
pageInfo: PageInfo
}
type PlaylistEdge {
node: Playlist
}
type PlaylistConnection {
edges: [PlaylistEdge!]
cursor: ID
pageInfo: PageInfo
}
type ActivityEdge {
node: Activity
}
type ActivityConnection {
edges: [ActivityEdge!]
cursor: ID
pageInfo: PageInfo
}
type StationEdge {
node: Station
}
type StationConnection {
edges: [StationEdge!]
cursor: ID
pageInfo: PageInfo
}
type MusicVideoEdge {
node: MusicVideo
}
type MusicVideoConnection {
edges: [MusicVideoEdge!]
cursor: ID
pageInfo: PageInfo
}
type CuratorEdge {
node: Curator
}
type CuratorConnection {
edges: [CuratorEdge!]
cursor: ID
pageInfo: PageInfo
}
type ChartsResultEdge {
node: ChartsResult
}
type ChartsResultConnection {
edges: [ChartsResultEdge]
cursor: ID
pageInfo: PageInfo
}
type SearchResultEdge {
node: SearchResult
}
type SearchResultConnection {
edges: [SearchResultEdge]
cursor: ID
pageInfo: PageInfo
}
interface Node {
id: ID!
name: String
}
type Curator implements Node {
id: ID!
name: String!
editorialNotes: EditorialNotes
artwork: Artwork
}
type Playlist implements Node {
id: ID!
name: String!
description: EditorialNotes
curatorName: String
canEdit: Boolean
curator: Curator
artwork: Artwork
tracks(first: Int = 25, after: ID = NULL): SongConnection
"authenticated only"
liked: Boolean
}
type Album implements Node {
id: ID!
name: String!
albumName: String
artistName: String
isSingle: Boolean
isComplete: Boolean
trackCount: Int
recordLabel: String
copyright: String
contentRating: String
releaseDate: String
isMasteredForItunes: Boolean
editorialNotes: EditorialNotes
artwork: Artwork
artists(first: Int = 25, after: ID = NULL): ArtistConnection
tracks(first: Int = 25, after: ID = NULL): SongConnection
}
type Artist implements Node {
id: ID!
name: String!
editorialNotes: EditorialNotes
albums(first: Int = 25, after: ID = NULL): AlbumConnection
}
type Song implements Node {
id: ID!
name: String!
albumName: String
trackNumber: Int
composerName: String
artistName: String
contentRating: String
discNumber: Int
durationInMillis: Float
isrc: String
releaseDate: String
artwork: Artwork
editorialNotes: EditorialNotes
albums(first: Int = 25, after: ID = NULL): AlbumConnection
artists(first: Int = 25, after: ID = NULL): ArtistConnection
"authenticated only"
liked: Boolean
}
type Activity implements Node {
id: ID!
name: String
artwork: Artwork
playlists(first: Int = 10, after: ID = NULL): PlaylistConnection
}
type Station implements Node {
id: ID!
name: String
artwork: Artwork
durationInMillis: Float
editorialNotes: EditorialNotes
episodeNumber: Int
isLive: Boolean
}
type MusicVideo implements Node {
id: ID!
albumName: String
artistName: String!
artwork: Artwork!
contentRating: String
durationInMillis: Float
editorialNotes: EditorialNotes
isrc: String!
name: String!
releaseDate: String!
trackNumber: Int
hasHDR: Boolean
has4K: Boolean
albums(first: Int = 10, after: ID = NULL): AlbumConnection
artists(first: Int = 10, after: ID = NULL): ArtistConnection
"authenticated only"
liked: Boolean
}
type History {
heavyRotation: [Node]
recentlyPlayed: [Node]
recentlyAdded: [Node]
recentStations: [Node]
}
type User {
history: History
albums(first: Int = 25, after: ID = NULL): AlbumConnection
artists(first: Int = 25, after: ID = NULL): ArtistConnection
songs(first: Int = 25, after: ID = NULL): SongConnection
playlists(first: Int = 25, after: ID = NULL): PlaylistConnection
musicVideos(first: Int = 25, after: ID = NULL): MusicVideoConnection
}
type EditorialNotes {
short: String
standard: String
}
type Artwork {
url(w: Int = 600, h: Int = 600): String
}
enum SearchType {
PLAYLISTS
ARTISTS
ALBUMS
MUSIC_VIDEO
ACTIVITIES
STATIONS
SONGS
}
union SearchResult =
Song
| Album
| Artist
| Playlist
| MusicVideo
| Activity
| Station
| Curator
union ChartsResult = Album | Song | Playlist
type Query {
me: User
charts(first: Int = 25, after: ID = NULL): ChartsResultConnection
search(
query: String!
type: [SearchType!]!
first: Int = 25
after: ID = NULL
): SearchResultConnection
node(id: ID!): Node
}
"If you do not specify a playlist, it adds to the library instead"
input AddInput {
playlist: ID
songs: [ID]!
}
# TODO: figure out what the hell to return
type AddPayload {
clientMutationId: String
}
input RatingInput {
id: ID!
like: Boolean!
clientMutationId: String
}
type RatingPayload {
node: Node
}
input CreatePlaylistInput {
name: String!
description: String
songs: [ID!]
clientMutationId: String
}
type CreatePlaylistPayload {
playlist: Playlist
clientMutationId: String
}
type Mutation {
createPlaylist(input: CreatePlaylistInput): CreatePlaylistPayload
add(input: AddInput): AddPayload
rate(input: RatingInput): RatingPayload
}
`;
module.exports = typeDefs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment