Skip to content

Commit

Permalink
update with final
Browse files Browse the repository at this point in the history
  • Loading branch information
Liz Hennessy authored and Liz Hennessy committed Feb 6, 2024
2 parents 23a800e + 3afd6cb commit c341759
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 216 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ node_modules/
# Intellij Configuration Files
.idea/

generated-schema.graphql
# Always regenerate new types before running project
src/types.ts
2 changes: 1 addition & 1 deletion codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ const config: CodegenConfig = {
},
};

export default config;
export default config;
209 changes: 0 additions & 209 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export type DataSourceContext = {
dataSources: {
spotifyAPI: SpotifyAPI;
};
};
};
24 changes: 24 additions & 0 deletions src/datasources/spotify-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { RESTDataSource } from "@apollo/datasource-rest";

export class SpotifyAPI extends RESTDataSource {
baseURL = "https://spotify-demo-api-fe224840a08c.herokuapp.com/v1/";

async getFeaturedPlaylists() {
const { playlists = [] } = await this.get("browse/featured-playlists");
const { items = [] } = playlists;
return items;
}

addItemsToPlaylist(input: { playlistId: string; uris: string[] }) {
const { playlistId, uris } = input;
return this.post(`playlists/${playlistId}/tracks`, {
params: {
uris: uris.join(","),
},
});
}

getPlaylist(playlistId: string) {
return this.get(`playlists/${playlistId}`);
}
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ async function startApolloServer() {
`);
}

startApolloServer();
startApolloServer();
2 changes: 1 addition & 1 deletion src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export type AddItemsToPlaylistPayloadModel = {
success: boolean;
message: string;
playlistId: string;
}
}
2 changes: 1 addition & 1 deletion src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export const resolvers: Resolvers = {
return durationMs;
}
}
}
}
2 changes: 1 addition & 1 deletion src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ export const typeDefs = gql`
"The URI for the track, usually a Spotify link."
uri: String!
}
`;
`;

0 comments on commit c341759

Please sign in to comment.